(Exodus 13:18) "And God led the people around." For what purpose? In order to perform for them miracles and mighty deeds. Rabbi Eliezer says: the road, in order to wear them out, as it is said, "He has worn out my strength on the way" (Psalms 102:24); the wilderness, in order to refine them, as it is said (Deuteronomy 8:15), "who led you through the great and terrible wilderness," and so forth; the Sea of Reeds, to test them, as it is said, "they rebelled at the sea, at the Sea of Reeds" (Psalms 106:7). Rabbi Joshua says: the road, in order to give them the Torah, as it is said (Deuteronomy 5:30), "in all the way that the LORD your God has commanded you, you shall walk," and it says (Proverbs 6:23), "For the commandment is a lamp and the Torah a light, and the way of life"; the wilderness, in order to feed them the manna, as it is said, "who fed you manna in the wilderness" (Deuteronomy 8:16); the Sea of Reeds, in order to perform for them miracles and mighty deeds, as it is said (Psalms 106:22), "awesome deeds at the Sea of Reeds," and it is said (Psalms 106:9), "He rebuked the Sea of Reeds and it dried up."
Why the Road, the Wilderness, and the Sea Were Each a Gift
Yalkut Shimoni on Torah 227:5
(שמות יג יח) וַיַּסֵּב אֱלֹהִים אֶת הָעָם, מִפְּנֵי מָה, כְּדֵי לַעֲשוֹת לָהֶם נִסִּים וּגְבוּרוֹת. רַבִּי אֱלִיעֶזֶר אוֹמֵר, דֶּרֶךְ כְּדֵי לְיַגְּעָן, שֶׁנֶּאֱמַר "עִנָּה בַדֶּרֶךְ כֹּחִי", הַמִּדְבָּר כְּדֵי לְצָרְפָן, שֶׁנֶּאֱמַר (דברים ח, טו) "הַמּוֹלִיכֲךָ בַּמִּדְבָּר הַגָּדֹל וְהַנּוֹרָא" וְגוֹ', יַם סוּף לְנַסּוֹתָן, שֶׁנֶּאֱמַר "וַיַּמְרוּ עַל יָם בְּיַם סוּף". רַבִּי יְהוֹשֻׁעַ אוֹמֵר, דֶּרֶךְ כְּדֵי לִתֵּן לָהֶם אֶת הַתּוֹרָה, שֶׁנֶּאֱמַר (דברים ח, ל) "בְּכָל הַדֶּרֶךְ אֲשֶׁר צִוָּה ה' (אֱלֹהֵינוּ) [אֱלֹהֵיכֶם] אֶתְכֶם תֵּלֵכוּ", וְאוֹמֵר (משלי ו, כג) "כִּי נֵר מִצְוָה וְתוֹרָה אוֹר וְדֶרֶךְ חַיִּים", הַמִּדְבָּר, כְּדֵי לְהַאֲכִילָן הַמָּן, שֶׁנֶּאֱמַר "הַמַּאֲכִלְךָ מָן בַּמִּדְבָּר", יַם סוּף כְּדֵי לַעֲשׂוֹת לָהֶם נִסִּים וּגְבוּרוֹת, שֶׁנֶּאֱמַר (תהלים קו, כב) "נוֹרָאוֹת עַל יַם סוּף" וְנֶאֱמַר (שם ט) "וַיִּגְעַר בְּיַם סוּף וַיְּחֱרָב".