I just observed an on-line remote funeral service for my cousin. As part of the service, the Rabbi took out a bag of sand which he said was specially flown in from Jerusalem. He spread the sand in the grave. He said it is believed that when the Messiah comes, all of those who are buried in Jerusalem will arise in good shape. If you are not buried in Jerusalem, you will have to roll over there and will not arrive in good shape. In the 1st century, therefore, someone came up with the idea that if you are buried with some sand from Jerusalem, then all will be well when the Messiah comes. Can anyone shed some light on this practice?
The Rema in Yoreh Deah 363:1 writes:
יש נוהגין לתת מעפר א"י בקבר (א"ז) (ויש למנהג זה על מה שיסמוכו) (מדרש תנחומא פ' ויחי)
Some have the custom to place some earth from the Land of Israel in the grave (Refer to the Or Zaruah) (and this custom has a basis - see Midrash Tanchuma Parshas Vayechi)
The Midrash writes over there a reference to the fact that the Avos (the Patriarchs) sought to be buried in the land of Israel, as there, people will be resurrected first when Moshiach arrives. I assume the reference, in light of your question is if one has some earth from Israel buried with them, even when not in Israel, it has some strength to the resurrection process.
Indeed, in the Sefer Maavar Yabok, Sefas Emes, chapter 27 that speaks about this topic it writes:
כי עפר הארץ שיצה חוצה לארץ דינו כעפר ישראל
Because the dirt of the land (of Israel) that goes out to chutz la'aretz (outside the land of Israel) has the status like that of the dirt of Israel.
אמר ליה כיון שהן מגיעין לארץ ישראל הן נוטלין גוש עפר ומניחין על ארונן דכתיב וכפר אדמתו עמו
They said to him, when they arrive in Eretz Yisroel, they place a piece of dirt and put it on the coffin as it writes (Devarim 32:43), "And cleanse the land of His people".
However, he then questions the minhag (custom) by asking what actual benefit it brings i.e. there's no inherent difference in dirt.
This custom is also mentioned in Nitei Gavriel on aveilus 49:17.