The Messenger of Allah ﷺ said, "Women are married for four reasons, for their wealth, for their lineage, for their beauty, and for their religion. So choose the one with religion, may your hands be rubbed with dust."
حدثنا يحيى بن حكيم حدثنا يحيى بن سعيد عن عبيد الله بن عمر عن سعيد بن أبي سعيد عن أبيه
أن رسول الله ﷺ قال تنكح النساء لأربع لمالها ولحسبها ولجمالها ولدينها فاظفر بذات الدين تربت يداك
Bukhari narrated it in the Book of Marriage, chapter "Equals in Religion," etc., no. 5090, and Muslim in the Book of Breastfeeding, chapter "The recommendation of marrying a religious woman," no. 1466, from the hadith of Yahya bin Saeed with the same wording.