The Talmud (Yoma 9B) tells us that the first Bet Hamiqdash was destroyed because of three grave sins that had become widespread in Israel - idolatry, sexual immorality and murder. What is remarkable about this description of the failings that lead to the destruction of the First Temple is that the very same trio of sins plays a significant role in another connection.
As a general principle, a Jew whose life is endangered as a result of Torah observance is commanded to violate the laws of the Torah rather than perish. However, there are three exceptions to this rule; no matter what the circumstances, even to save his life, a Jew is never permitted to engage in idolatry, illicit sexual relations or homicide. These commandments represent the core values of Judaism - the Unity of God, the intrinsic sanctity of human life, and our mandate to transcend our base instincts so as to promote those ideals.
Ordinary mitsvot are means to an end, they are designed to help us make the most out of our lives. Thus, it would be absurd to sacrifice our lives on their account. This would transform them from contructive tools of perfection into agents of destruction.
On the other hand, the three core sins embody the metaphysical principles of Judaism, they are outward expressions of our inner convictions about God and human nature. They are not means to an end - they point to the end itself. As such, unlike the remaining commandments of the Torah, they are not expendable under any circumstances. To compromise on them, even for a moment, would be to contradict the fundamentals of our belief, the values that make life itself worth living.
Casting these ideas aside for the sake of physical existence would be a travesty, as it would imply that our individual biological/instinctual life is an object of value in its own right whose preservation takes precedence over the affirmation of God's existence and/or His relationship with mankind. This is a hillul Hashem, a desecration of God's name, because it ascribes greater significance to material reality than metaphysical reality.The mitzvah of Qiddush Hashem, on the other hand, directs us to promote quite the opposite perspective - namely, that the metaphysical is of ultimate value, utterly transcending and even trumping the material, the particular, and the mundane.
Therefore, as the Rambam explains in the Laws of the Fundamentals of the Torah, sacrificing one's life for the sake of observing these mitsvot is a fulfillment of the commandment to sanctify God's name, as it is written in the Torah, "and I shall be sanctified in the midst of the Children of Israel." A Jew who violates one of these precepts in order to preserve his life is considered to have desecrated God's name through his surrender.
With this in mind, we can perhaps understand why it is the three "cardinal sins" that were responsible for the destruction of the Bet Hamiqdash. The Torah states in several places in the books of Shemot, Vayiqra and Devarim, that the ultimate purpose of the Miqdash was to provide a vehicle for communal "Qiddush Hashem" - hence the name "miqdash", which is derived from the term for sanctity or holiness. The Kohanim are commanded to sanctify God's name through their religious service, Torah teaching, and personal conduct. The edifice of the Sanctuary was designed to inspire visitors with love and reverence for the Creator of the Universe.
The Miqdash's function of sanctifying Hashem's name, however, can only be achieved when it is situated amidst a nation that is dedicated to that objective. It was designed as a means to the end of Qiddush Hashem - an institution through which the Jewish people were to accomplish their collective aim. As such, the Miqdash must be in the "right hands" for its potential to be actualized. A nation engaged in activities that are the very negation of qiddush Hashem cannot possibly appreciate, maintain or participate in the operation of a Sanctuary that is consecrated to the lofty end of elevating humanity's consciousness of God.
Therefore, it is perfectly understandable why the Jews lost the privilege of a Holy Temple as soon as they demonstrated a complete lack of commitment to Qiddush Hashem and engaged in idolatry, illicit sexual behavior and murder. These grave sins clearly indicated the alienation of the Jewish people from the core principles of Torah, principles for which one would ordinarily sacrifice one's life, and, therefore, a total disconnection from the purpose for which the Miqdash was brought into existence in the first place.
When the Jewish people abandoned their mission of Qiddush Hashem, they effectively transformed the Temple's operation into a desecration rather than a sanctification of Hashem's name. Tragically, the Miqdash was now misconstrued as an emblem of God's purported endorsement of the metaphysically bankrupt lifestyle of the Jewish people rather than a source of inspiration that would encourage them to transcend their petty pursuits.
The Jews' wanton disregard for the real objective of the Miqdash created a situation in which the Miqdash could no longer function properly and in which - since its true nature was ignored or distorted - it would, as an institution, inevitably be hijacked for corrupt purposes. The destruction of the Bet Hamiqdash, and its absence from our nation to this day, is the ultimate indication that we are not yet prepared to embrace the noble mission of Qiddush Hashem for which Hashem chose our forefathers.