(Genesis 9:22:) "And Ham, the father of Canaan, saw <the nakedness of his father>." Rabbi Judah bar Shallum said in the name of Rabbi Jacob bar Zavdi, who said in the name of Rabbi Abbahu: Ham saw with his eyes and told with his mouth. Therefore the Holy One, blessed be He, said: If one of the slaves is struck in his eye or in his tooth, he goes out to freedom, as it is said (Exodus 21:26): "And if a man strikes the eye of his slave <or the eye of his maidservant and destroys it, he shall let him go free for his eye>."
Why Ham's Eye and Mouth Set Slaves Free in Tanchuma Noach
Midrash Tanchuma Buber, Noach 21:1
וירא חם אבי כנען (בראשית ט כב). אמר ר' יהודה בר שלום בשם ר' יעקב בר זבדי שאמר משום ר' אבהו הם ראה בעיניו והגיד בפיו, לפיכך אמר הקב"ה אם ילקה אחד מן העבדים בעינו או בשינו יצא לחירות, שנאמר וכי יכה איש את [עין] עבדו וגו' (שמות כא כ).