"Now Moses was tending [the flock]." And why was the section "And it came to pass in those many days" (Exodus 2:23) placed adjacent to this section? Because the Holy One, blessed be He, knows that Moses is righteous and gives his life for his children, and that if Moses fled to Midian, he would be their redeemer; therefore it is written, "Now Moses was tending," and so forth. "And he led the flock [behind the wilderness, and he came to the mountain of God, to Horeb]." For forty days and forty nights the flock of Jethro went and tasted nothing, just as Elijah went, as it is said, "And he went in the strength of [that] eating [forty days and forty nights, unto Horeb the mountain of God]" (1 Kings 19:8). Another interpretation: "behind the wilderness." And why was he pursuing after the wilderness? Because he foresaw by the Holy Spirit that he would lay waste the cities of the nations, as it is said, "Behold, the end of the nations is a wilderness, a parched land" (Jeremiah 3, near 12). "And he led the flock [behind the wilderness]." He announced to him that his flock would perish in the wilderness, and afterward he would be gathered to his people; and therefore the flock of Moses went forty days and forty nights and tasted nothing, corresponding to the forty years that he would lead Israel in the wilderness, when they tasted nothing from the sowing of the ground, and they were forty years, a day for a year, and they all died in the wilderness, and he too was gathered with them. "And he came to the mountain of God, to Horeb." And once he reached Horeb, immediately "the angel of the Lord appeared to him in a flame of fire" — in order to embolden him, so that he would come to Sinai and see the fires and the torches and not be afraid of them. Another interpretation: "in a flame of fire" (be-labbat esh). Do not read "be-labbat esh" but rather "be-libbat esh" (in the heart of fire), to teach you that He revealed Himself above two parts of Sinai.
Moses Shepherds Jethro's Flock to Horeb and the Burning Bush
Midrash Aggadah, Exodus 3:1
ומשה היה רעה. ולמה נסמכה פרשת ויהי בימים הרבים ההם (שמות ב כג), לפרשה זו, לפי שהקב"ה יודע שמשה צדיק ונותן נפשו על בניו, ואם ברח למדין משה גואלם, לכך כתיב ומשה היה רעה וגו': וינהג את הצאן. [אחר המדבר ויבא אל הר האלהים חורבה]. ארבעים יום וארבעים לילה הלכה צאנו של יתרו ולא טעמו כלום, כשם שהלך אליהו, שנאמר וילך בכח האכילה [ההיא ארבעים יום וארבעים לילה עד הר האלהים חורב] (מ"א יט ח): ד"א אחר המדבר, ולמה היה רודף אחר המדבר, לפי שצפה ברוח הקודש שיחריב כרכיהם של אומות, שנאמר הנה אחרית גוים מדבר ציה (ירמי' ג' יב): וינהג את הצאן [אחר המדבר]. בישרו שצאנו יכלה במדבר, ואחר כך נאסף אל עמיו, ולכך הלכה צאנו של משה ארבעים יום וארבעים לילה, שלא טעמה כלום, כנגד ארבעים שנה שינהיג את ישראל במדבר, שלא טעמו מזריעת אדמה כלום, והם ארבעים שנה יום לשנה, וכולם מתו במדבר, ואף הוא נאסף עמהם: ויבא אל הר האלהים חרבה. וכיון שהגיע לחורב מיד וירא (אליו ה') [מלאך ה' אליו] בלבת אש. כדי ללבבו, ויבא לסיני ויראה האשות והלפידים, ולא יתירא מהם: ד"א בלבת אש. אל תקרי בלבת אש אלא בליבת אש, ללמדך שנגלה למעלה משני חלקים של סיני: