[(Exodus 31:18:) AND HE GAVE TO MOSES.] This is what Scripture said (Proverbs 2:6): FOR THE LORD GIVES WISDOM; [FROM HIS MOUTH COME KNOWLEDGE AND UNDERSTANDING. Great is wisdom, and greater than it are knowledge and understanding. FOR THE LORD GIVES WISDOM,] but to the one whom He loves He gives, [from His mouth,] knowledge and understanding. Rabbi Isaac said: To what is the matter comparable? To a king who had a son, and he would come from the schoolhouse. He found a serving-dish before his father. His father took a piece and gave it to him. What did his son do? He said to him: I want only what is in your mouth. Because he cherished him, he gave him from within his mouth. [Thus] (Proverbs 2:6): FOR THE LORD GIVES WISDOM, but to the one whom He loves, from His mouth come knowledge and understanding. As a gift the Holy One, blessed be He, gave the Torah to Israel: (Exodus 31:18) AND HE GAVE TO MOSES.
Why God Gives Knowledge from His Mouth to Those He Loves
Midrash Tanchuma Buber, Ki Tisa 10:1
[ויתן אל משה]. זש"ה כי ה' יתן חכמה [מפיו דעת ותבונה (משלי ב ו), גדולה היא החכמה, וגדולה ממנה הדעת והתבונה, כי ה' יתן חכמה], אבל למי שהוא אוהב (יתן) [מפיו] דעת ותבונה. ר' יצחק אמר למה הדבר דומה למלך שהיה לו בן, והיה בא מבית הספר, מצא תמחוי לפני אביו, נטל אביו חתיכה ונתן לו, מה עשה בנו אמרלו איני מבקש אלא מה שבתוך פיך, מתוך שהיה מחבבו נתן לו מתוך פיו, [הוי] כי ה' יתן חכמה, אבל מי שהוא אוהב מפיו דעת ותבונה. במתנה נתן הקב"ה תורה לישראל, ויתן אל משה.