(As it is said:) "And the sons of Noah who went forth from the ark were [Shem, Ham, and Japheth]" (Genesis 9:18). Now was Shem the eldest, that he is placed first? Is it not written, "the brother of Japheth the elder" (Genesis 10:21)? Why, then, did Scripture place Shem before Japheth? Because he was worthy and perfect toward his Creator.
Why Shem Comes Before Japheth Among Noah's Sons
Midrash Tanchuma Buber, Noach 19:3
(שנאמר) ויהיו בני נח היוצאים מן התבה [שם וחם ויפת], וכי שם היה גדול שהוא מקדימו, והלא כתיב אחי יפת הגדול (בראשית י כא), למה הקדים שם ליפת, שהיה כשר ומושלם לבוראו.