This midrash discusses the soul's attachment to Torah and the spiritual significance of human formation, complementing the Talmudic image of instruction before birth. It provides a homiletic Chazal source related to the same cluster of ideas.
וּמַבִּיט וְרוֹאֶה מִסּוֹף הָעוֹלָם וְעַד סוֹפוֹ. נוֹטְלוֹ הַמַּלְאָךְ מִשָּׁם וּמוֹלִיכוֹ לְגַן עֵדֶן וּמַרְאֶה לוֹ הַצַּדִּיקִים יוֹשְׁבִין בְּכָבוֹד וְעַטְרוֹתֵיהֶם בְּרָאשֵׁיהֶם. וְאוֹמֵר הַמַּלְאָךְ לְאוֹתוֹ הָרוּחַ, תֵּדַע לְךָ מִי הֵם אֵלּוּ. אוֹמֵר לוֹ הָרוּחַ, לֹא אֲדוֹנִי. חוֹזֵר הַמַּלְאָךְ וְאוֹמֵר לוֹ: הַלָּלוּ שֶׁאַתָּה רוֹאֶה, נוֹצְרוּ בַתְּחִלָּה כְּמוֹתְךָ בְּתוֹךְ מְעֵי אִמָּן וְיָצְאוּ לָעוֹלָם וְשָׁמְרוּ הַתּוֹרָה וְהַמִּצְוֹת, לְפִיכָךְ זָכוּ וְנִזְדַּמְּנוּ לְטוֹבָה זוֹ שֶׁאַתָּה רוֹאֶה. דַּע לְךָ, שֶׁסּוֹפְךָ לָצֵאת לָעוֹלָם. וְאִם תִּזְכֶּה וְתִשְׁמֹר הַתּוֹרָה שֶׁל הַקָּדוֹשׁ בָּרוּךְ הוּא, תִּזְכֶּה לְכָךְ וְלַיְּשִׁיבָה שֶׁל אֵלּוּ. וְאִם לָאו, דַּע וּרְאֵה שֶׁתִּזְכֶּה לְמָקוֹם אַחֵר. לָעֶרֶב, מוֹלִיכוֹ לְגֵיהִנָּם. וּמַרְאֶה לוֹ שָׁם אֶת הָרְשָׁעִים שֶׁמַּלְאֲכֵי חַבָּלָה מַכִּים אוֹתָן בְּמַקְלוֹת שֶׁל אֵשׁ, וְקוֹרְאִין וַי וַי וְאֵינָם מְרַחֲמִים עֲלֵיהֶם. וְאוֹמֵר לוֹ עוֹד אוֹתוֹ מַלְאָךְ לְאוֹתוֹ הָרוּחַ, תֵּדַע מִי הֵן אֵלּוּ. וְאוֹמֵר: לֹא אֲדוֹנִי. וְאוֹמֵר לוֹ הַמַּלְאָךְ, אֵלּוּ הַנִּשְׂרָפִין, נוֹצְרוּ כְּמוֹתְךָ וְיָצְאוּ לָעוֹלָם וְלֹא שָׁמְרוּ הַתּוֹרָה וְחֻקּוֹתָיו שֶׁל הַקָּדוֹשׁ בָּרוּךְ הוּא, לְכָךְ בָּאוּ לְחֶרְפָּה זוֹ שֶׁאַתָּה רוֹאֶה. וְאַתָּה דַע לְךָ, שֶׁסּוֹפְךָ לָצֵאת לָעוֹלָם, וֶהֱוֵי צַדִּיק וְאַל תְּהִי רָשָׁע, וְתִזְכֶּה וְתִחְיֶה לָעוֹלָם הַבָּא. וּמִנַּיִן שֶׁהוּא כֵן. שֶׁנֶּאֱמַר: כִּי בֵן הָיִיתִי לְאָבִי רַךְ וְיָחִיד לִפְנֵי אִמִּי, וַיֹּרֵנִי וַיֹּאמֶר לִי יִתְמָךְ דִּבָרַי לִבֶּךָ, שְׁמֹר מִצְוֹתַי וֶחְיֵּה (משלי ד, ג-ד). כִּי בֵן הָיִיתִי לְאָבִי, קֹדֶם שֶׁיָּצָאתִי מִמְּעֵי אִמִּי, הָיִיתִי בְּנוֹ שֶׁל הַקָּדוֹשׁ בָּרוּךְ הוּא, כִּי כֵן יִסְּרַנִּי כְּמוֹ הָאָב שֶׁמְּיַסֵּר אֶת בְּנוֹ. רַךְ וְיָחִיד לִפְנֵי אִמִּי, הָעֵת שֶׁהָיִיתִי רַךְ וְהָיִיתִי יָחִיד שֶׁלֹּא הָיָה שׁוּם אָדָם בַּחֲבוּרָתִי לִפְנֵי אִמִּי. וַיֹּרֵנִי הַמַלְאָךְ וַיֹּאמֶר לִי, יִתְמָךְ דְּבָרַי לִבֶּךָ שְׁמֹר מִצְוֹתַי וֶחְיֵה, כְּמוֹ שֶׁנֶּאֱמַר לְעֵיל. וּלְכָךְ עַל הַכֹּל מַזְהִירוֹ הַקָּדוֹשׁ בָּרוּךְ הוּא. וּמְטַיֵּל אוֹתוֹ הַמַּלְאָךְ מִן הַבֹּקֶר וְעַד הָעֶרֶב, וּמַרְאֶה לוֹ מָקוֹם שֶׁהוּא עָתִיד לָמוּת בּוֹ וּמָקוֹם שֶׁהוּא עָתִיד לְהִקָּבֵר בּוֹ, וְאַחַר כָּךְ מוֹלִיכוֹ וּמְטַיְּלוֹ עַל כָּל הָעוֹלָם וּמַרְאֶה לוֹ אֶת הַצַּדִּיקִים וְאֶת הָרְשָׁעִים, וּמַרְאֶה לוֹ הַכֹּל. וּבָעֶרֶב חוֹזְרוֹ לְתוֹךְ מְעֵי אִמּוֹ, וְהַקָּדוֹשׁ בָּרוּךְ הוּא עוֹשֶׂה לוֹ שָׁם בְּרִיחַ וּדְלָתַיִם, שֶׁנֶּאֱמַר: וַיָּסֶךְ בִּדְלָתַיִם יָם (איוב לח, ח). וּכְתִיב: וָאָשִׂם דְּבָרַי בְּפִיךָ וּבְצֵל יָדִי כִּסִּיתִיךָ (ישעיה נא, טז). עוֹמֵד וְאוֹמֵר לוֹ הַקָּדוֹשׁ בָּרוּךְ הוּא, עַד פֹּה תָבוֹא וְלֹא תֹסִיף וְגוֹ' (איוב לח, יא).
He looked about and peered from one end of the world to the other. The angel took him and led him into the Garden of Eden and showed him the righteous ones sitting there in honor, with crowns on their heads. The angel said to him: “O soul, do you know who these are?” And the soul replied: “No, my master.” Whereupon the angel told him: “These that you see were formed at first, like you, in the womb of their mothers, and then went out into the world. They observed the Torah and the commandments, and therefore were deserving and were selected for this beautiful place that you see. Know that when you leave this world, if you are worthy and keep the law of the Holy One, blessed be He, you will merit sitting among these. But if not, be assured, you will be assigned to another place.” That evening he led him to the netherworld and showed him the wicked ones whom the demons were smiting with brands of fire and who were crying: “Woe is me, woe is me,” and none had mercy for them. The angel then said to the soul: “Do you know who these are?” And he replied: “No, my master.” Whereupon the angel told him: “These are the ones who will be consumed. They were formed like you and went out into the world, but they did not keep the Torah and the statutes of the Holy One, blessed be He, and that is why they have come to this disgraceful end that you are witnessing. Be assured that you will ultimately leave this world, but if you are righteous and not wicked, you will be worthy to enjoy life in the world-to-come.” How do we know that this is so? From the fact that it is said: For I was a son unto my father, tender and an only one in the sight of my mother. And he taught me, and said unto me: “Let thy heart hold fast upon My words, keep My commandments and live” (Prov. 4:3–4). For I was a son unto my father indicates that before I left my mother’s womb I was the son of the Holy One, blessed be He, who rebuked me as a father rebukes his son. Tender and an only one in the sight of my mother alludes to the time I was tender and alone and no one was with me in my mother’s womb. Then the angel instructed me and told me: “Take my words to heart, keep my commandments and it shall be as described above.” The Holy One, blessed be He, then warned him concerning everything that would transpire, and the angel led him about from morning until evening. He showed him where he would die and where he would be buried. Then he led him about and walked with him through the world, showing him the righteous and the wicked and everything else. In the evening he brought him back to his mother’s womb. The Holy One, blessed be He, fashioned bolts and doors (Job 38:10) before him, as it is said: Or who shut up the sea with the doors? (ibid., v. 8), and I have put My words in thy mouth, and have covered thee in the shadow of My hand (Isa. 51:6). Then He said to him: Thus far shalt you come, but no farther (Job 38:11).