"And the LORD spoke to Moses after the death <of Aaron's two sons>, etc." (Leviticus 16:1). This is what Scripture says (Ecclesiastes 9:2): "All things come alike to all; there is one fate for the righteous and for the wicked, etc." Solomon was looking and gazing upon all the generations, upon the righteous and upon the wicked, and he saw things that reach the wicked and reach the righteous, and he says (Ecclesiastes 9:3): "This is an evil in all that is done under the sun, that there is one fate for all." "All things come alike to all; there is one fate for the righteous" — this is Abraham, who is called righteous, as it is said (Genesis 18:19): "For I have known him, [so that] he may command <his children and his household after him>, [to do righteousness]." "And for the wicked" — this is Nimrod, who incited the whole world entire to rebel against the Holy One, blessed be He. This one died and that one died. "For the good and for the clean [and for the unclean] (Ecclesiastes 9:2); for the good]" — this is David, as it is said (1 Samuel 16:12): "Of beautiful eyes and goodly to look upon." "For the unclean" — this is Nebuchadnezzar. This one laid the foundations of the House of the Sanctuary, and that one destroyed it; this one reigned forty years, and that one reigned forty years. "For the one who sacrifices" (Ecclesiastes 9:2) — this is Solomon, as it is said (1 Kings 8:63): "And Solomon offered the sacrifice of peace offerings, which he sacrificed to the LORD, twenty-two thousand oxen." "And for the one who does not sacrifice" (Ecclesiastes 9:2) — this is Jeroboam, who prevented Israel from going up for the pilgrimage festival, as it is said (1 Kings 12:28): "It is too much for you to go up to Jerusalem, etc." This one reigned after that one. "As is the good" (Ecclesiastes 9:2) — this is Moses, as it is said (Exodus 2:2): "And she saw him, that he was good." "So is the sinner" (Ecclesiastes 9:2) — these are the spies, as it is said (Proverbs 13:21): "Evil pursues sinners." Moses did not enter the land, and they did not enter the land. "The one who swears" (Ecclesiastes 9:2) — this is Zedekiah, as it is said (2 Chronicles 36:13): "And he also rebelled against King Nebuchadnezzar, who had made him swear [by God], etc." "As the one who fears an oath" (Ecclesiastes 9:2) — this is Samson, as it is said (Judges 15:12): "And Samson said [to] them, 'Swear to me, etc.'" The eyes of this one were blinded, and the eyes of that one were blinded.
One Fate for the Righteous and the Wicked in Tanchuma
Midrash Tanchuma Buber, Achrei Mot 1:1
וידבר ה' אל משה אחרי מות וגו' (ויקרא טז א). זש"ה הכל כאשר לכל מקרה אחד לצדיק ולרשע וגו' (קהלת טב), שלמה היה מביט וצופה בכל הדורות בצדיקים וברשעים, וראה דברים שמגיעין לרשעים ומגיעין לצדיקים, ואומר זה רע בכל אשר נעשה תחת השמש כי מקרה אחד לכל (שם שם ג), הכל כאשר לכל מקרה אחד לצדיק, זה אברהם שנקרא צדיק, שנאמר כי ידעתיו [למען] אשר יצוה וגו' [לעשות צדקה] (בראשית יח יט), לרשע זה נמרוד, שהמריד את כל העולם כולו בהקב"ה, זה מת וזה מת. לטוב ולטהור [ולטמא (קהלת שם), לטוב] זה דוד, שנאמר יפה עינים וטוב רואי (ש"א טז יב), לטמא זה נבוכדנצר, זה בנה יסודי בית המקדש, וזה החריבו, זה מלך ארבעים שנה, וזה מלך ארבעים שנה, לזובח (קהלת שם), זה שלמה, שנאמר ויזשלמה את זבח השלמים אשר זבח לה' בקר עשרים ושנים אלף (מ"א ח סג), לאשר איננו זובח (קהלת שם), זה ירבעם, שביטל ישראל מלעלות לרגל, שנאמר רב לכם מעלות ירושלים וגו' (מ"א יב כח), זה מלך אחר זה. כטוב (קהלת שם), זה משה, שנאמר ותרא אותו כי טוב הוא (שמות ב ב), כחוטא (קהלת שם), זה מרגלים, שנאמר חטאים תרדף רעה (משלי יג כא), משה לא נכנס לארץ, והם לא נכנסו לארץ, הנשבע (קהלת שם), זה צדקיהו, שנאמר גם במלך נבוכדנצר מרד אשר השביעו (אלהים) [באלהים] וגו' (דה"ב לו יג). (כל אשר) [כאשר] שבועה ירא (קהלת שם), זה שמשון, שנאמר ויאמר (אליהם) [להם] שמשון השבעו ליוגו' (שופטים טו יב), לזה עוורו עיניו, ולזה עוורו עיניו.