"Therefore He takes knowledge of their works, and He overturns them in the night, so that they are crushed" (Job 34:25). Rabbi Chanina said: The Holy One, blessed be He, never exacts punishment from a nation first, until He has first exacted punishment from its prince above. This is what is written: "And it shall come to pass in that day, that the LORD shall visit [yifkod] upon the host on high, on high" (Isaiah 24:21), and afterward "and upon the kings of the earth, upon the earth" (ibid.). So too, at first "the sons of God saw the daughters of men" (Genesis 6:2), and afterward "And the LORD saw that the wickedness of man was great" (ibid. 6:5), and afterward "And the LORD said: I will blot out man" etc. (ibid. 6:7). So too, at first "Amalek came" (Exodus 17:8), and afterward "Remember what Amalek did to you" (Deuteronomy 25:17), and afterward "Thus says the LORD of hosts: I have remembered [pakadti] what Amalek did to Israel" (1 Samuel 15:2). Rabbi Acha said: I am a keeper of deposits. Sarah deposited with me a bundle of commandments [mitzvot]; therefore "And the LORD remembered [pakad] Sarah" (Genesis 21:1). But Amalek deposited with me a bundle of thorns; therefore "Thus says the LORD of hosts: I have remembered [pakadti what Amalek did to Israel]" (1 Samuel 15:2).
Why God Judges the Heavenly Prince Before the Nation Below
Midrash Shmuel 18:1
לכן יכיר מעבדיהם והפך לילה וידכאו (איוב ל"ד כ"ה), אמר רבי חנינא לעולם אין הקדוש ברוך הוא נפרע מאומה תחילה עד שיפרע משרה שלמעלן, הדא הוא דכתיב והיה ביום ההוא יפקוד ה' על צבא המרום במרום (ישעי' כ"ד כ"א) ואחר כך ועל מלכי האדמה באדמה (שם), כך בתחילה ויראו בני האלהים את בנות האדם (בראשית ו' ב'), ואחר כך וירא ה' כי רבה רעת האדם (שם שם ה'), ואחר כך ויאמר ה' אמחה את האדם וגו' (שם שם ז'), כך בתחלה ויבא עמלק (שמות י"ז ח'), ואחר כך זכור את אשר עשה לך עמלק (דברים כ"ה י"ז) ואחר כך כה אמר ה' צבאות פקדתי את אשר עשה עמלק לישראל (שמואל א' ט"ו ב'). אמר רבי אחא בעל פקדונות אני, שרה הפקידה אצלי חבילה של מצות לפיכך וה' פקד את שרה (בראשית כ"א א'), אבל עמלק הפקיד אצלי חבילה של קוצים לפיכך כה אמר ה' צבאות פקדתי [את אשר עשה עמלק לישראל] (שמואל א' ט"ו ב').