"And he fought with Israel at Rephidim" (Exodus 17:8). Rabbi Hanina said: This matter I asked of Rabbi Eliezer, who sat in the great academy: What is Rephidim? He said to him: It is to be understood according to its plain meaning. And further Rabbi Hanina said: I asked Rabbi Eliezer, What did Israel see fit to redeem the firstborn of donkeys, and not to redeem the firstborn of horses, nor the firstborn of camels? He said to him: It is the decree of the King; and further, because Israel had in their possession at that hour none but donkeys, since there was not a single Israelite who did not come away with ninety donkeys laden with silver and gold. Others say: Rephidim means nothing other than "slackness of hands" [rifyon yadayim], because they let their hands grow slack from the words of the Torah; therefore the enemy came upon them, for the enemy comes only upon slackness of hands in Torah, as it is said, "And it came to pass, when the kingdom of Rehoboam was established and he was strong, that he forsook the Torah of the LORD, and all Israel with him" (2 Chronicles 12:1). And what is the punishment of this matter? "And it came to pass in the fifth year of King Rehoboam, that Shishak king of Egypt came up against Jerusalem," and so on, "and he took away the treasures of the house of the LORD" (2 Chronicles 12:2, 9). This is one of three things that returned to their place. The exile of Judah returned to its place, as it is said, "Your fathers dwelt beyond the River" (Joshua 24:2), and it is written, "and he destroyed this house and carried the people away captive to Babylon" (Ezra 5:12). The writing of heaven returned to its place, as it is said, "Will you set your eyes upon it? It is gone" (Proverbs 23:5). The silver of Egypt returned to its place.
Why Amalek Came at Rephidim and the Slackening of Torah
Yalkut Shimoni on Torah 263:1
וַיִּלָּחֶם עִם יִשְׂרָאֵל בִּרְפִידִם. אָמַר רַבִּי חֲנִינָא, הַדָּבָר הַזֶּה שָׁאַלְתִּי אֶת רַבִּי אֱלִיעֶזֶר שֶׁהָיָה יוֹשֵב בִּמְתִיבְתָּא רַבָּה, מַהוּ רְפִידִם. אָמַר לֵיהּ, כְּמַשְׁמָעוֹ, וְעוֹד אָמַר רַבִּי חֲנִינָא, שָׁאַלְתִּי אֶת רַבִּי אֱלִיעֶזֶר, מֶה רָאוּ יִשְׂרָאֵל לִפְדוֹת פִּטְרֵי חֲמוֹרִים וְלֹא לִפְדוֹת פִּטְרֵי סוּסִים וְלֹא פִּטְרֵי גְּמַלִּים. אָמַר לֵיהּ, גְּזֵרַת הַמֶּלֶךְ הִיא, [וְעוֹד] שֶׁלֹּא הָיוּ בְיָדָן שֶׁל יִשְׂרָאֵל אֶלָּא חֲמוֹרִים בִּלְבַד בְּאוֹתָהּ שָׁעָה לְפִי שֶׁאֵין כָּל אֶחָד מִיִּשְׂרָאֵל שֶׁלֹּא עָלוּ בְיָדוֹ תִּשְׁעִים חֲמוֹרִים טְעוּנִים כֶּסֶף וְזָהָב. אֲחֵרִים אוֹמְרִים, אֵין רְפִידִם אֶלָּא רִפְיוֹן יָדַיִם, לְפִי שֶׁרָפוּ יְדֵיהֶם מִדִּבְרֵי תּוֹרָה לְכַךְ בָּא הַשּׂוֹנֵא עֲלֵיהֶם, לְפִי שֶׁאֵין הַשּׁוֹנֵא בָּא אֶלָּא עַל רִפְיוֹן יָדַיִם מִן הַתּוֹרָה, שֶׁנֶּאֱמַר "וַיְהִי כְּהָכִין מַלְכוּת רְחַבְעָם וּכְחֶזְקָתוֹ עָזַב אֶת תּוֹרַת ה' וְכָל יִשְׂרָאֵל עִמּוֹ", וּמָה הוּא עוֹנְשׁוֹ שֶׁל דָּבָר, (שם, ב) "וַיְהִי בַּשָּׁנָה הַחֲמִישִׁת [לַמֶּלֶךְ] רְחַבְעָם עָלָה שִׁישַׁק מֶלֶךְ מִצְרַיִם עַל יְרוּשָׁלָ(י)ם" וְגוֹ' "וַיִּקַּח אֶת אֹצְרוֹת בֵּית ה'". וְזוֹ הִיא אֶחָד מִשְּׁלוֹשָׁה דְּבָרִים שֶׁחָזְרוּ לִמְקוֹמָן, גָּלוּת יְהוּדָה חָזְרָה לִמְקוֹמָהּ, שֶׁנֶּאֱמַר (יהושע כד, ב) "בְּעֵבֶר הַנָּהָר יָשְׁבוּ אֲבוֹתֵיכֶם, וּכְתִיב (עזרא ה, יב) "וּבַיְתָה דְנָה סַתְרֵהּ וְעַמָּהּ הַגְלִי לְבָבֶל". כְּתַב שָׁמַיִם חָזַר לִמְקוֹמוֹ, שֶׁנֶּאֱמַר (משלי כג, ה) "הֲתָעִיף עֵינֶיךָ בּוֹ וְאֵינֶנּוּ". כֶּסֶף מִצְרַיִם חָזַר לִמְקוֹמוֹ.