"You stretched out Your right hand" (Exodus 15:12). This teaches that all souls are in the palm of the Holy One, blessed be He, as it is said, "In whose hand is the soul of every living thing" (Job 12:10), "into Your hand I entrust my spirit" (Psalms 31:6). "The earth swallowed them." By what merit did the Omnipresent grant them burial? By the merit that they said, "The LORD is righteous" (Exodus 9:27). The Omnipresent said to them: You declared the judgment against yourselves to be just; I too will not withhold your reward, and I will give you a place of burial, as it is said, "You stretched out Your right hand."
You Stretched Out Your Right Hand and Why the Egyptians Earned a Grave
Yalkut Shimoni on Torah 251:1
(שמות טו יב) נָטִיתָ יְמִינְךָ. מַגִּיד שֶׁכָּל הַנְּפָשׁוֹת בְּכַף הַקָּדוֹשׁ בָּרוּךְ הוּא, שֶׁנֶּאֱמַר (איוב יב, י) "אֲשֶׁר בְּיָדוֹ נֶפֶשׁ כָּל חָי בְּיָדְךָ אַפְקִיד רוּחִי". תִּבְלָעֵמוֹ אָרֶץ. בְּאֵיזֶה זְכוּת נָתַן לָהֶם הַמָּקוֹם קְבוּרָה, בִּזְכוּת שֶׁאָמְרוּ "ה' הַצַּדִּיק". אָמַר לָהֶם הַמָּקוֹם, אַתֶּם צִדַּקְתֶּם עֲלֵיכֶם אֶת הַדִּין, אַף אֲנִי לֹא אֲקַפַּח שְׂכַרְכֶם וְאֶתֵּן לָכֶם מְקוֹם קְבוּרָה, שֶׁנֶּאֱמַר נָטִיתָ יְמִינְךָ.