A close examination of scripture reveals Rachael's death and burial location as falling short of reaching Ephrath. Jacob made mention of this:
Gen 48:7 As for me, when I came from Paddan, Rachel died beside me in
the land of Canaan on the way, when there was still some distance to
come to Ephrath, and I buried her there on the way to Ephrath (also
called Bethlehem).” (WEB)
A more precise location of Rachael's burial grounds is found in 1 Sam 10:2. Samuel told young Saul (after his anointing) he would meet men near Rachael's tomb, on the border of Benjamin at Zelzah: Zelah being a few miles southwest of Jerusalem.
1Sa 10:2 When you have departed from me today, then you will find
two men by Rachel’s tomb, on the border of Benjamin at Zelzah. They
will tell you, ‘The donkeys which you went to look for have been
found; and behold, your father has stopped caring about the donkeys,
and is anxious for you, saying, “What shall I do for my son".
Why did Jeremiah ascribe weeping to Rachael?
First, we must go back to the context of Gen 35:16-19. Here we find Rachael in the hard labor that would lead to her death. There are two interesting events that transpire during this time. One, Rachael was comforted by her handmaiden with these words:
“Don’t be afraid, for now you will have another son.” Gen 35:17.
Two, Rachel names her son Benomi, which means "son of my pain/sorrow".
For Rachael the source of her physical pain and her hope rested in giving birth to a child. As with other biblical women, the hope of bearing children was linked to the birth of the savior (Gen 3:15).
The prophet Jeremiah figuratively describes a weeping Rachael when the residents of Judah (which contained a large element of tribal Benjamin) are gathered at Ramah by the Babylonian army and deported to Babylon.
But notice the words of consolation that are given to the weeping Rachael in Jer 31.
Jer 31:16 Yahweh says: “Refrain your voice from weeping, and your
eyes from tears; for your work will be rewarded,” says Yahweh. “They
will come again from the land of the enemy".
It's from Yahweh. God assures Rachael that the deported children will return to the land. The evil Nebuchadnezzar seemingly ended the Promise of Israel, but God promises a return of His nation.
Matthew, under the inspiration of God, picked up on Rachael's weeping theme to describe her sorrow of the killing of the innocents in Matt 2:18 (arguably some of her physical descendants). Here again, her offspring being the subject of sorrow and promise. Although no consolation is given Rachael in this passage as previously done, Matthew subsequently chronicled the exiled Jesus and return from Egypt to prove how the life of young Jesus fulfilled key historical aspects of national Israel's history. In other words, although there was sorrow and pain throughout Judea, true consolation had arrived via the birth of the Savior.