"And he said: Cursed be Canaan" (Genesis 9:25). Ham looked — is Canaan cursed? Rabbi Judah said: The curse does not dwell in a place of blessing, since it is stated, "And God blessed [Noah and his sons]" (Genesis 9:1). [Rabbi Nehemiah says:] Canaan looked and told his father, so the curse returned to its origin; therefore it is stated, "And he said: Cursed be Canaan." Our Rabbis said: When Noah was in the ark, he said: Were my sons to have slaves, so that they might sit while those slaves went forth before them — but when I go out from the ark, whatever I beget I will make into slaves for them. He said to him (Ham): You did not allow me to beget a fourth son who would be a slave to his brothers; by your life, I will make your fourth son a slave, as it is stated, "And he said: Cursed be Canaan; [a slave of slaves shall he be to his brothers]" (Genesis 9:25). Resh Lakish said: Behold, those of Ham are slaves forever, but the sons of Shem go forth free in the world, as it is stated, "If [a fellow Hebrew] is sold to you" (Deuteronomy 15:12), "and you shall take the awl" (Deuteronomy 15:17). What is written there? "And he shall be your slave forever" (Deuteronomy 15:17). But here, "a slave of slaves" — a slave who takes no freedom and never goes out into the world. What caused this curse for him? Through his disgracing his father. And so too the Holy One, blessed be He, is destined to exact payment from the sons of Ham and to disgrace them through the king of Assyria, as it is stated, "So shall the king of Assyria lead [the captives] … [naked and barefoot]" (Isaiah 20:4). What is "naked and barefoot"? That he would disgrace them and lead them about naked. And Japheth, who honored his father — how did the Holy One, blessed be He, repay him? When Gog comes, the Holy One, blessed be He, darkens and covers over him, as it is stated, "And it shall come to pass on that day that I will give to Gog a place there for a grave" (Ezekiel 39:11). And how did the Holy One, blessed be He, repay Shem? When the sons of Aaron entered to offer sacrifice, their bodies were burned but their garments were not burned — why? Because they are the sons of Shem. This is among the righteous; and from where among the wicked? When Sennacherib went up against Jerusalem and all his armies with him, their bodies were burned but their garments were not burned — why? Because they are among the sons of the sons of Shem, as it is stated, "The sons of Shem: Elam, Asshur, Arpachshad, Lud, and Aram" (Genesis 10:22).
Why Noah Cursed Canaan and the Fate of Ham, Shem, and Japheth
Midrash Tanchuma Buber, Noach 21:4
ויאמר ארור כנען (שם כה). חם ראה כנען נתארר, אמר ר' יהודה אין הקללה שוכנת במקום ברכה, לפי שנאמר ויברך אלהים [את נח ואת בניו, (שם א) ר' נחמיה אומר] כנען ראה והגיד לאביו חזרה קללה לעיקרה, לפיכך נאמר ויאמר ארור כנען. אמרו רבותינו כשהיה נח בתבה, אמר אילו היו לבני עבדים, כדי שהיו יושבים והם יוצאים לפניהם, אלא כשאצא מן התבה מה שאני מוליד אעשה אותם עבדים להם, אמר לו אתה לא הנחת לי להוליד בן רביעי שיהא עבד לאחיו, חייך אני אעשה בנך הרביעי עבד, שנאמר ויאמר ארור כנען [עבד עבדים יהיה לאחיו (בראשית ט כה) ], אמר ריש לקיש הרי משל חם עבדים לעולם, אבל בניו של שם יוצאים חפשים בעולם, שנאמר כי ימכר לך (דברים טו יב), ולקחת את המרצע (שם שם יז), מה כתיב שם והיה לך עבד (לעולם) [עולם] (שם שם), אבל כאן עבד עבדים, עבד שאינו נוטל חירות ולא יצא לעולם, מי גרם לו הארירה הזאת על ידי שביזה את אביו, וכן עתיד הקב"ה לפרוע מבניו של חם ולבזותם על ידי מלך אשור, שנאמר כן ינהג מלך אשור וגו' [ערום ויחף] (ישעיה כ ד), מהו ערום ויחף, שהיה מבזה אותן ומוליכן ערומים, ויפת שכיבד את אביו, מה פרע לו הקב"ה, כשיבא גוג הקב"ה מאפילו ומכסה עליו, שנאמר והיה ביום ההוא אתן לגוג מקום שם קבר (יחזקאל לא יא), ומה פרע לו הקב"ה לשם, אלא בשעה שנכנסו בניו של אהרן להקריב, נשרפו גופיהם, ולא נשרפו בגדיהם, למה שהם בניו של שם, הרי בצדיקים, ומנין ברשעים, בשעה שעלה סנחריב לירושלים וכל חיילותיו עמו, נשרפו גופיהן ולא נשרפו בגדיהם, למה שהן מבני בניו של שם, שנאמר בני שם עילם ואשור וארפכשד ולוד וארם (בראשית י כב).