Trying to understand Genesis 48:7 with Nehama Leibowitz's guidance
(ז) וַאֲנִ֣י ׀ בְּבֹאִ֣י מִפַּדָּ֗ן מֵ֩תָה֩ עָלַ֨י רָחֵ֜ל בְּאֶ֤רֶץ כְּנַ֙עַן֙ בַּדֶּ֔רֶךְ בְּע֥וֹד כִּבְרַת־אֶ֖רֶץ לָבֹ֣א אֶפְרָ֑תָה וָאֶקְבְּרֶ֤הָ שָּׁם֙ בְּדֶ֣רֶךְ אֶפְרָ֔ת הִ֖וא בֵּ֥ית לָֽחֶם׃
(7) I [do this because], when I was returning from Paddan, Rachel died, to my sorrow, while I was journeying in the land of Canaan, when still some distance short of Ephrath; and I buried her there on the road to Ephrath”—now Bethlehem.
(יז) וַיָּ֣קָם ׀ שְׂדֵ֣ה עֶפְר֗וֹן אֲשֶׁר֙ בַּמַּכְפֵּלָ֔ה אֲשֶׁ֖ר לִפְנֵ֣י מַמְרֵ֑א הַשָּׂדֶה֙ וְהַמְּעָרָ֣ה אֲשֶׁר־בּ֔וֹ וְכָל־הָעֵץ֙ אֲשֶׁ֣ר בַּשָּׂדֶ֔ה אֲשֶׁ֥ר בְּכָל־גְּבֻל֖וֹ סָבִֽיב׃ (יח) לְאַבְרָהָ֥ם לְמִקְנָ֖ה לְעֵינֵ֣י בְנֵי־חֵ֑ת בְּכֹ֖ל בָּאֵ֥י שַֽׁעַר־עִירֽוֹ׃ (יט) וְאַחֲרֵי־כֵן֩ קָבַ֨ר אַבְרָהָ֜ם אֶת־שָׂרָ֣ה אִשְׁתּ֗וֹ אֶל־מְעָרַ֞ת שְׂדֵ֧ה הַמַּכְפֵּלָ֛ה עַל־פְּנֵ֥י מַמְרֵ֖א הִ֣וא חֶבְר֑וֹן בְּאֶ֖רֶץ כְּנָֽעַן׃ (כ) וַיָּ֨קָם הַשָּׂדֶ֜ה וְהַמְּעָרָ֧ה אֲשֶׁר־בּ֛וֹ לְאַבְרָהָ֖ם לַאֲחֻזַּת־קָ֑בֶר מֵאֵ֖ת בְּנֵי־חֵֽת׃ (ס)
(17) So Ephron’s land in Machpelah, near Mamre—the field with its cave and all the trees anywhere within the confines of that field—passed (18) to Abraham as his possession, in the presence of the Hittites, of all who entered the gate of his town. (19) And then Abraham buried his wife Sarah in the cave of the field of Machpelah, facing Mamre—now Hebron—in the land of Canaan. (20) Thus the field with its cave passed from the Hittites to Abraham, as a burial site.
(ז) וְאֵ֗לֶּה יְמֵ֛י שְׁנֵֽי־חַיֵּ֥י אַבְרָהָ֖ם אֲשֶׁר־חָ֑י מְאַ֥ת שָׁנָ֛ה וְשִׁבְעִ֥ים שָׁנָ֖ה וְחָמֵ֥שׁ שָׁנִֽים׃ (ח) וַיִּגְוַ֨ע וַיָּ֧מָת אַבְרָהָ֛ם בְּשֵׂיבָ֥ה טוֹבָ֖ה זָקֵ֣ן וְשָׂבֵ֑עַ וַיֵּאָ֖סֶף אֶל־עַמָּֽיו׃ (ט) וַיִּקְבְּר֨וּ אֹת֜וֹ יִצְחָ֤ק וְיִשְׁמָעֵאל֙ בָּנָ֔יו אֶל־מְעָרַ֖ת הַמַּכְפֵּלָ֑ה אֶל־שְׂדֵ֞ה עֶפְרֹ֤ן בֶּן־צֹ֙חַר֙ הַֽחִתִּ֔י אֲשֶׁ֖ר עַל־פְּנֵ֥י מַמְרֵֽא׃ (י) הַשָּׂדֶ֛ה אֲשֶׁר־קָנָ֥ה אַבְרָהָ֖ם מֵאֵ֣ת בְּנֵי־חֵ֑ת שָׁ֛מָּה קֻבַּ֥ר אַבְרָהָ֖ם וְשָׂרָ֥ה אִשְׁתּֽוֹ׃
(7) This was the total span of Abraham’s life: one hundred and seventy-five years. (8) And Abraham breathed his last, dying at a good ripe age, old and contented; and he was gathered to his kin. (9) His sons Isaac and Ishmael buried him in the cave of Machpelah, in the field of Ephron son of Zohar the Hittite, facing Mamre, (10) the field that Abraham had bought from the Hittites; there Abraham was buried, and Sarah his wife.
(ח) וַתָּ֤מָת דְּבֹרָה֙ מֵינֶ֣קֶת רִבְקָ֔ה וַתִּקָּבֵ֛ר מִתַּ֥חַת לְבֵֽית־אֵ֖ל תַּ֣חַת הָֽאַלּ֑וֹן וַיִּקְרָ֥א שְׁמ֖וֹ אַלּ֥וֹן בָּכֽוּת׃ (פ)
(8) Deborah, Rebekah’s nurse, died, and was buried under the oak below Bethel; so it was named Allon-bacuth.
(יט) וַתָּ֖מָת רָחֵ֑ל וַתִּקָּבֵר֙ בְּדֶ֣רֶךְ אֶפְרָ֔תָה הִ֖וא בֵּ֥ית לָֽחֶם׃ (כ) וַיַּצֵּ֧ב יַעֲקֹ֛ב מַצֵּבָ֖ה עַל־קְבֻרָתָ֑הּ הִ֛וא מַצֶּ֥בֶת קְבֻֽרַת־רָחֵ֖ל עַד־הַיּֽוֹם׃ (כא) וַיִּסַּ֖ע יִשְׂרָאֵ֑ל וַיֵּ֣ט אָֽהֳלֹ֔ה מֵהָ֖לְאָה לְמִגְדַּל־עֵֽדֶר׃
(19) Thus Rachel died. She was buried on the road to Ephrath—now Bethlehem. (20) Over her grave Jacob set up a pillar; it is the pillar at Rachel’s grave to this day. (21) Israel journeyed on, and pitched his tent beyond Migdal-eder.
(כז) וַיָּבֹ֤א יַעֲקֹב֙ אֶל־יִצְחָ֣ק אָבִ֔יו מַמְרֵ֖א קִרְיַ֣ת הָֽאַרְבַּ֑ע הִ֣וא חֶבְר֔וֹן אֲשֶׁר־גָּֽר־שָׁ֥ם אַבְרָהָ֖ם וְיִצְחָֽק׃ (כח) וַיִּֽהְי֖וּ יְמֵ֣י יִצְחָ֑ק מְאַ֥ת שָׁנָ֖ה וּשְׁמֹנִ֥ים שָׁנָֽה׃ (כט) וַיִּגְוַ֨ע יִצְחָ֤ק וַיָּ֙מָת֙ וַיֵּאָ֣סֶף אֶל־עַמָּ֔יו זָקֵ֖ן וּשְׂבַ֣ע יָמִ֑ים וַיִּקְבְּר֣וּ אֹת֔וֹ עֵשָׂ֥ו וְיַעֲקֹ֖ב בָּנָֽיו׃ (פ)
(27) And Jacob came to his father Isaac at Mamre, at Kiriath-arba—now Hebron—where Abraham and Isaac had sojourned. (28) Isaac was a hundred and eighty years old (29) when he breathed his last and died. He was gathered to his kin in ripe old age; and he was buried by his sons Esau and Jacob.
(כח) וַיְחִ֤י יַעֲקֹב֙ בְּאֶ֣רֶץ מִצְרַ֔יִם שְׁבַ֥ע עֶשְׂרֵ֖ה שָׁנָ֑ה וַיְהִ֤י יְמֵֽי־יַעֲקֹב֙ שְׁנֵ֣י חַיָּ֔יו שֶׁ֣בַע שָׁנִ֔ים וְאַרְבָּעִ֥ים וּמְאַ֖ת שָׁנָֽה׃ (כט) וַיִּקְרְב֣וּ יְמֵֽי־יִשְׂרָאֵ֘ל לָמוּת֒ וַיִּקְרָ֣א ׀ לִבְנ֣וֹ לְיוֹסֵ֗ף וַיֹּ֤אמֶר לוֹ֙ אִם־נָ֨א מָצָ֤אתִי חֵן֙ בְּעֵינֶ֔יךָ שִֽׂים־נָ֥א יָדְךָ֖ תַּ֣חַת יְרֵכִ֑י וְעָשִׂ֤יתָ עִמָּדִי֙ חֶ֣סֶד וֶאֱמֶ֔ת אַל־נָ֥א תִקְבְּרֵ֖נִי בְּמִצְרָֽיִם׃ (ל) וְשָֽׁכַבְתִּי֙ עִם־אֲבֹתַ֔י וּנְשָׂאתַ֙נִי֙ מִמִּצְרַ֔יִם וּקְבַרְתַּ֖נִי בִּקְבֻרָתָ֑ם וַיֹּאמַ֕ר אָנֹכִ֖י אֶֽעֱשֶׂ֥ה כִדְבָרֶֽךָ׃ (לא) וַיֹּ֗אמֶר הִשָּֽׁבְעָה֙ לִ֔י וַיִּשָּׁבַ֖ע ל֑וֹ וַיִּשְׁתַּ֥חוּ יִשְׂרָאֵ֖ל עַל־רֹ֥אשׁ הַמִּטָּֽה׃ (פ)
(28) Jacob lived seventeen years in the land of Egypt, so that the span of Jacob’s life came to one hundred and forty-seven years. (29) And when the time approached for Israel to die, he summoned his son Joseph and said to him, “Do me this favor, place your hand under my thigh as a pledge of your steadfast loyalty: please do not bury me in Egypt. (30) When I lie down with my fathers, take me up from Egypt and bury me in their burial-place.” He replied, “I will do as you have spoken.” (31) And he said, “Swear to me.” And he swore to him. Then Israel bowed at the head of the bed.
(כט) וַיְצַ֣ו אוֹתָ֗ם וַיֹּ֤אמֶר אֲלֵהֶם֙ אֲנִי֙ נֶאֱסָ֣ף אֶל־עַמִּ֔י קִבְר֥וּ אֹתִ֖י אֶל־אֲבֹתָ֑י אֶל־הַ֨מְּעָרָ֔ה אֲשֶׁ֥ר בִּשְׂדֵ֖ה עֶפְר֥וֹן הַֽחִתִּֽי׃ (ל) בַּמְּעָרָ֞ה אֲשֶׁ֨ר בִּשְׂדֵ֧ה הַמַּכְפֵּלָ֛ה אֲשֶׁ֥ר עַל־פְּנֵי־מַמְרֵ֖א בְּאֶ֣רֶץ כְּנָ֑עַן אֲשֶׁר֩ קָנָ֨ה אַבְרָהָ֜ם אֶת־הַשָּׂדֶ֗ה מֵאֵ֛ת עֶפְרֹ֥ן הַחִתִּ֖י לַאֲחֻזַּת־קָֽבֶר׃ (לא) שָׁ֣מָּה קָֽבְר֞וּ אֶת־אַבְרָהָ֗ם וְאֵת֙ שָׂרָ֣ה אִשְׁתּ֔וֹ שָׁ֚מָּה קָבְר֣וּ אֶת־יִצְחָ֔ק וְאֵ֖ת רִבְקָ֣ה אִשְׁתּ֑וֹ וְשָׁ֥מָּה קָבַ֖רְתִּי אֶת־לֵאָֽה׃ (לב) מִקְנֵ֧ה הַשָּׂדֶ֛ה וְהַמְּעָרָ֥ה אֲשֶׁר־בּ֖וֹ מֵאֵ֥ת בְּנֵי־חֵֽת׃ (לג) וַיְכַ֤ל יַעֲקֹב֙ לְצַוֺּ֣ת אֶת־בָּנָ֔יו וַיֶּאֱסֹ֥ף רַגְלָ֖יו אֶל־הַמִּטָּ֑ה וַיִּגְוַ֖ע וַיֵּאָ֥סֶף אֶל־עַמָּֽיו׃
(29) Then he instructed them, saying to them, “I am about to be gathered to my kin. Bury me with my fathers in the cave which is in the field of Ephron the Hittite, (30) the cave which is in the field of Machpelah, facing Mamre, in the land of Canaan, the field that Abraham bought from Ephron the Hittite for a burial site— (31) there Abraham and his wife Sarah were buried; there Isaac and his wife Rebekah were buried; and there I buried Leah— (32) the field and the cave in it, bought from the Hittites.” (33) When Jacob finished his instructions to his sons, he drew his feet into the bed and, breathing his last, he was gathered to his people.

Ramban on Genesis 48:7

The plain explanation is that Jacob spoke in an apologetic tone pleading with Joseph not to be angry with him for this last request to bury him in the Cave of Machpelah on the grounds that he had not buried his mother there, as he had done for Leah. For this reason, he said to him that she had died in the land of Canaan and that she had not been buried outside the Holy Land as would be the case for Jacob should his remains be left in Egypt.

Rachel, he explained, had died on the journey suddenly and he had not been able to bury her in the family tomb. For how could he have left his children and cattle on the way and have gone quickly to the Cave of Machpelah? Where were the embalmers and medicaments to embalm her?

This is the implication of the word alayei - unto me or upon me. Though the Cave of Machpelah was not more than half a day's journey from where Rachel died, Jacob was heavily burdened with cattle and members of his household and would only have been able to reach there in a number of days. Indeed it took him many days until he reached his father's home.

(ד) בדרך בעוד כברת ארץ לבא אפרתה תכף כשנסעתי מאותו המקום שהיה דבר האל יתברך אלי בעודי בדרך אפרת. וכל כך גברה עלי טרדתי ואבלותי שלא עצרתי כח להוליכ' לבית קברות בית לחם ואין ספק כי מאז היה לבי חלל בקרבי ...

(4) בדרך בעוד כברת ארץ לבא אפרתה, immediately after G’d finished speaking to me before I had even arrived at Beyt Lechem, ואקברה שם בדרך אפרת, and I had to bury her there on the route to Efrat; I was so overcome by grief at the time that I did not even have the strength to transport her remains to the burial grounds in Beyt Lechem. There is no doubt that ever since her death my heart was so full of grief...

תנא אין איש מת אלא לאשתו ואין אשה מתה אלא לבעלה אין איש מת אלא לאשתו שנאמר (רות א, ג) וימת אלימלך איש נעמי ואין אשה מתה אלא לבעלה שנאמר (בראשית מח, ז) ואני בבאי מפדן מתה עלי רחל:
It is taught in a baraita: A man dies only to his wife, i.e., it is primarily she who suffers the pain and sadness resulting from his death, and a woman dies only to her husband. A man dies only to his wife, as it is stated: “And Elimelech, Naomi’s husband, died” (Ruth 1:3), and a woman dies only to her husband, as it is stated in Jacob’s parting words to Joseph: “And as for me, when I came from Paddan, Rachel died on me” (Genesis 48:7).
(א) וטעם ואני בבואי מפדן. שמתה רחל פתאום ולא יכולתי להוליכה לקברה במערה כאשר קברתי לאה. ואמר זה ליוסף שלא יחר לך שאבקש מאתך מה שלא עשיתי לכבוד אמך

Rachel died suddenly and I could not bury her in the Cave as I buried Leah. He mentioned this to Joseph that he should not be angry for asking him for something which he had not done on behalf of his mother.

(א) ואני בבאי מפדן וגו'. וְאַעַ"פִּ שֶׁאֲנִי מַטְרִיחַ עָלֶיךָ לְהוֹלִיכֵנִי לְהִקָּבֵר בְּאֶרֶץ כְּנַעַן, וְלֹא כָךְ עָשִׂיתִי לְאִמְּךָ, שֶׁהֲרֵי מֵתָה סָמוּךְ לְבֵית לֶחֶם:
(1) 'ואני בבאי מפדן וגו AND AS FOR ME, WHEN I CAME FROM PADAN etc. — “And although I trouble you to take me for burial into the land of Canaan and I did not do this for your mother (i.e., I did not take the trouble to bury her in a place other than that in which she died, which was by the road-side) which I might easily have done since she died quite close to Bethlehem”.

(ג) אקברה שם. וְלֹא הוֹלַכְתִּיהָ אֲפִלּוּ לְבֵית לֶחֶם לְהַכְנִיסָהּ לָאָרֶץ, וְיָדַעְתִּי שֶׁיֵּשׁ בְּלִבְּךָ עָלַי; אֲבָל דַּע לְךָ שֶׁעַל פִּי הַדִּבּוּר קְבַרְתִּיהָ שָׁם, שֶׁתְּהֵא לְעֶזְרָה לְבָנֶיהָ כְּשֶׁיַּגְלֶה אוֹתָם נְבוּזַרְאֲדָן, וְהָיוּ עוֹבְרִים דֶּרֶךְ שָׁם, יוֹצֵאת רָחֵל עַל קִבְרָהּ וּבוֹכָה וּמְבַקֶּשֶׁת עֲלֵיהֶם רַחֲמִים, שֶׁנֶּאֱמַר קוֹל בְּרָמָה נִשְׁמָע וְגוֹ' וְהַקָּבָּ"ה מְשִׁיבָהּ יֵשׁ שָׂכָר לִפְעֻלָּתֵךְ נְאֻם ה' וְשָׁבוּ בָנִים לִגְבוּלָם (ירמיהו ל"א).

(3) ואקברה שם AND I BURIED HERE THERE and did not carry her even the short distance to Bethlehem to bring her into a city. I know that in your heart you feel some resentment against me. Know, however, that I buried her there by the command of God”. And the future proved that God had commanded him to do this in order that she might help her children when Nebuzaradan would take them into captivity. For when they were passing along that road, Rachel came forth from her grave and stood by her tomb weeping and beseeching mercy for them, as it is said, (Jeremiah 31:15) “A voice is heard in Rama, [the sound of weeping … Rachel weeping for her children]”, and the Holy One, blessed be He, replied to her (v. 16) “Refrain from weeping, and your eyes from tears; There is a reward for your work, says the Eternal. (v. 17) they shall come back from their enemy's land. There is hope for the future, says the Eternal, for your children will return to their own border”.

Ramban on Genesis 48:7

At any rate there should be some allusion in the text to this idea (of Rashi's). Perhaps to this the text alludes when it repeats, "Rachel died unto me on the way...and I buried her there on the way" implying on the way that her children were destined to pass did she die and there she was buried for their sake, since she had not actually died "on the way" but at 'Ramah' which is a town in the land of Benjamin and there she was buried.

But what the text meant to suggest was that she was buried at a spot where her descendants were destined to pass, when they were on the way going in to exile. The text does not, however, explicitly refer to future events, but merely alludes to them.