[And Jacob saw that there was grain in Egypt (Genesis 42:1).] This is what Scripture says: "He who commands the sun, and it does not rise, and seals up the stars" (Job 9:7). (Rather, it speaks of Jacob and of his sons, who were likened to them, as it is said, "And behold, the sun and the moon and eleven stars were bowing down to me.") Behold all the wisdom of Job! And who does not know that if the Holy One, blessed be He, were to say to the sun or to the stars that they should not shine, that they would not shine? As it is said, "He who commands the sun, and it does not rise." Rather, it is concerning Jacob and his sons that He speaks [who were likened to them, as it is said, "Behold, the sun and the moon and eleven stars were bowing down to me" (Genesis 37:9)]. "He who commands the sun, and it does not rise" — for the twenty-two years that Joseph spent in Egypt apart from his father, the Holy Spirit was hidden from Jacob and from his sons. And he was not far from them, only a journey of four days or five days, yet they did not know that he was in Egypt. And before this, Jacob and his sons were great prophets. Do you wish to know? Once Joseph told them the dream, what does he say? "Shall we indeed come, I and your mother and your brothers?" And when he was sold, they did not know where he was. This is the meaning of "He who commands the sun, and it does not rise." Why so? So that the prophets should not become haughty. Therefore the Holy One, blessed be He, made known to them His power and showed them that they are nothing. And likewise you find concerning the greatest of the prophets, because he said, "And the matter that is too hard for you, [you shall bring to me]" (Deuteronomy 1:17). The Holy One, blessed be He, said to him: You are able to resolve a hard matter? By your life, I will show you! And when the case of the daughters of Zelophehad came before him, he began to find it difficult and did not know what to say, and he brought their case before the Lord, as it is said, "And Moses brought their case before the Lord" (Numbers 27:5). The Holy One, blessed be He, said to him: Did you not say, "The matter that is too hard for you"? Behold, what the women know, you do not know, as it is said, "The daughters of Zelophehad speak rightly" (ibid. 27:7) — these judge better than you. And also Samuel, who was weighed against Moses and Aaron, because he said to Saul, "I am the seer" (I Samuel 9:19), the Holy One, blessed be He, said to him: You said, "I am the seer"? By your life, tomorrow I will show you whether you are a seer, as it is said, "Fill your horn with oil and go; [I will send you] to Jesse the Bethlehemite, for I have seen among his sons a king for Myself" (I Samuel 16:1). When he went, what is written? "And it came to pass, when they came, that he saw Eliab and said, Surely the Lord's anointed is before Him" (ibid. 16:6). The Holy One, blessed be He, said to him: Are you the one who said, "I am the seer"? "Do not look upon his appearance" (ibid. 16:7). And also Jacob [and his sons] were prophets and sages, and nothing was hidden from them; yet once Joseph was sold, they did not know about him until the Holy One, blessed be He, [wished it]. Therefore, "He who commands the sun, and it does not rise."
Why the Holy Spirit Hid Joseph from Jacob for Twenty-Two Years
Midrash Tanchuma Buber, Miketz 6:1
[וירא יעקב כי יש שבר במצרים]. זש"ה האומר לחרס ולא יזרח וגו' (איוב ט ז), (אלא על יעקב ועל בניו אומר שנמשלו בהן, שנאמר והנה השמש והירח ואחד עשר כוכבים משתחוים לי), הרי כל חכמתו של איוב, ומי אינו יודע שאם אמר הקב"ה לשמש או לכוכבים שלא יזרחו, שאינן זורחין, שנאמר האומר לחרס ולא יזרח וגו', אלא על יעקב ועל בניו הוא אומר [שנמשלו בהן שנאמר הנה השמש והירח ואחד עשר כוכבים משתחוים לי (בראשית לז ט) ], האומר לחרס ולא יזרח, כ"ב שנה שעשה יוסף במצרים חוץ מאביו, נגנז רוח הקדש מיעקב ומבניו, ולא היה רחוק מהם אלא מהלך ד' ימים או ה' ימים, ולא היו יודעים שבמצרים היה, וקודם לכן נביאים גדולים היו יעקב ובניו, רצונך לידע כיון שאמר להם יוסף את החלום, מהו אומר, הבא נבא אני ואמך ואחיך, וכשנמכר לא היו יודעין היכן הוא, הוי האומר לחרס ולא יזרח, למה כך, שלא יהו הנביאים מתגאים, לכך הודע להם הקב"ה כחו והראה להם שאינן כלום, וכן אתה מוצא בגדול הנביאים, על שאמר והדבר אשר יקשה מכם וגו' (דברים א יז), אמר לו הקב"ה אתה יכול לפתור דבר קשה, חייך שאני מראה לך, וכיון שהגיע לפניו עסקן של בנות צלפחד, התחיל מתקשה בו ולא היה יודע מה לומר, והקריב משפטן לפני ה', שנאמר ויקרב משה את משפטן לפני ה' (במדבר כז ה). א"ל הקב"ה לא הייתה אומר הדבר אשר יקשה מכם וגו', הרי מה שהנשים יודעות אין אתה יודע, שנאמר כן בנות צלפחד דוברות וגו' (שם שם ז), אלו דנות יפה ממך, ואף שמואל שהיה שקול כנגד משה ואהרן, על שאמר לשאול אנכי הרואה (ש"א ט יט), א"ל הקב"ה אתה אמרת אנכי הרואה, חייך למחר אני מראה לך אם רואה אתה, שנאמר מלא קרנך שמן ולך (בא) [אשלחך] אל ישי בית הלחמי כי ראיתי בבניו לי מלך (ש"א טז א), כיון שהלך מה כתיב, ויהי בבואם וירא את אליאב ויאמר אך נגד ה' משיחו (שם שם ז), א"ל הקב"ה אתה הוא שאמרת אנכי הרואה, אל תבט אל מראהו וגו' (שם שם ז). ואף יעקב [ובניו] היו נביאים וחכמים, ולא היה דבר נטמן מהם, כיון שנמכר יוסף לא היו יודעים בו עד [שבקש] הקב"ה, לפיכך האומר לחרס ולא יזרח וגו'.