אמר רבה בר רב הונא כל אדם שיש בו תורה ואין
בו יראת שמים דומה לגזבר שמסרו לו מפתחות
הפנימיות ומפתחות החיצוניות לא מסרו לו בהי
עייל מכריז ר׳ ינאי חבל על דלית לי׳ דרתא
ותרעא לדרתא עביד
"Rabbah the son of Rav Huna said: 'A person possessing Torah but lacking yiras shomayim (fear of Heaven), is analogous to a treasurer who is entrusted with the keys to the innermost chamber but not to the outer. How can he possibly enter?' Rabbi Yannai declared: 'Woe to the person who lacks a domicile yet makes a door for it.' "1
Rashi explains that yiras shomayim is analogous to the outer portals through which one reaches the inner portals. When a person possesses yiras shomayim, he is careful to observe the mitzvos. Lack of yiras shomayim whether generally lacking, or lacking to a degree commensurate with one's Torah knowledge indicates that an individual is not in possession of the vital keys.
Truly, the primary purpose of Torah knowledge is to enable a person to perform mitzvos properly, i.e., to be aware of all the mitzvos and their ramifications.
The mitzvos are G-d's will or Supernal Desire. Regarding a person's soul powers, we observe that will differs from the other powers, for it must be fulfilled meticulously if it is to be a valid expression of one's desire; should action lack even a minor detail, the initiating will cannot be said to have been fulfilled. In this regard, desire is different from other powers such as intellect, emotion, sight and hearing.
There are varying classes of intellect. Wisdom relating to action is shallow and considered "coarse" intellect, inasmuch as it relates strictly to physical matters. Though this branch of intellect may contain much wisdom, since it deals strictly with physical matters it is regarded as the lowest branch of intellect. Knowledge of the soul is of the higher classes of intellect, and knowledge of G-dliness is particularly sublime. Although both these forms of wisdom contain concepts readily comprehensible to the average mind, as a rule they are extremely refined.
We thus observe that there are higher and lower categories of knowledge, and that within each specific category there are concepts of greater and lesser profundity. But even the least subtle concept of the lowest class of intellect is still a form of intellect.
The same is true with regard to emotion, sight and hearing. They all contain [ideal and] less-than-ideal levels, yet all these levels are considered to fall within their particular category. [For example, even if one does not have perfect vision he is still considered to be sighted; even if one hears with difficulty he is not considered deaf.] This is not the case with desire; gratification of desire comes only when it is fulfilled exactly.
Mitzvos are expressions of the Divine Will. In order that they be performed in accordance with His will, Torah study is necessary, for only then will a person know how to observe them properly, in the manner which G-d desired. The main objective of Torah study should therefore be the acquisition of knowledge regarding those laws that pertain to a person's everyday conduct. Many people transgress, albeit unwittingly, because they lack elementary knowledge of Torah laws.
In summary: Torah and yiras shomayim are the interior and exterior keys. Rabbi Yannai likens yiras shomayim and Torah to a door and its domicile. The ultimate purpose of Torah study is to learn how to properly perform mitzvos, which are all expressions of Divine Will. Will must be fulfilled exactly in order to be fulfilled at all, and so the mitzvos must be performed according to the Torah's laws.