Another interpretation: "on their right" - this is the mezuzah; "and on their left" - this is tefillin. Rabbi Pappus expounded: "To my mare among Pharaoh's chariots" (Song of Songs 1:9) - Pharaoh rode upon a male horse; as it were, the Holy One, blessed be He, revealed Himself to him upon a male horse, as it is said, "You trod the sea with Your horses" (Habakkuk 3:15). Pharaoh rode upon a female horse; as it were, He revealed Himself to him upon a female horse, as it is said, "To my mare among Pharaoh's chariots" (Song of Songs 1:9). Rabbi Akiva said to him: Enough for you, Pappus! It is written "to my mare." The Holy One, blessed be He, said: Just as I rejoiced over Egypt to destroy them, so was I poised to rejoice over Israel to destroy them. And what caused them to be saved? By the merit of "on their right and on their left" - by the merit of the Torah that they are destined to receive from the right, as it is said, "From His right hand a fiery law for them" (Deuteronomy 33:2); and "on their left" - this is tefillin, and so on, as above.
Saved at the Sea by the Merit of Torah and Mitzvot
Yalkut Shimoni on Torah 238:2
דָּבָר אַחֵר, מִימִינָם, זוֹ מְזוּזָה, וּמִשְּׂמֹאלָם, זוּ תְּפִלִּין. דָּרַשׁ רַבִּי פַּפּוּס, (שה"ש א, ט) "לְסֻסָתִי בְּרִכְבֵי פַרְעֹה", רָכַב פַּרְעֹה עַל סוּס זָכָר. כִּבְיָכוֹל נִגְלָה עָלָיו הַקָּדוֹשׁ בָּרוּךְ הוּא עַל סוּס זָכָר, שֶׁנֶּאֱמַר "דָּרַכְתָּ בַּיָּם סוּסֶיךָ". רָכַב פַּרְעֹה עַל סוּס נְקֵבָה, כִּבְיָכוֹל נִגְלָה עָלָיו עַל סוּס נְקֵבָה, שֶׁנֶּאֱמַר (שה"ש שם) "לְסֻסָתִי בְּרִכְבֵי פַרְעֹה". אָמַר לֵיהּ רַבִּי עֲקִיבָא, דַּיֶיךָ פַּפּוּס, לְסֻסָתִי כְּתִיב, אָמַר הַקָּדוֹשׁ בָּרוּךְ הוּא, כְּשֵׁם שֶׁשַּׂשְׂתִּי עַל מִצְרַיִם לְאַבְּדָן כָּךְ שַּׂשְׂתִּי עַל יִשְׂרָאֵל לְאַבְּדָן. וּמִי גָּרַם לָהֶן לְהִנָּצֵל, בִּזְכוּת מִימִינָם וּמִשְּׂמֹאלָם, בִּזְכוּת הַתּוֹרָה שֶׁהֵן עֲתִידִין לְקַבֵּל מִימִינָם, שֶׁנֶּאֱמַר "מִימִינוֹ אֵשׁ דָּת לָמוֹ", וּמִשְּׂמֹאלָם זוּ תְּפִלִּין וְכוּ' כְּדִלְעֵיל.