It was narrated from Abu Hurayrah (may Allaah be pleased with him) that the Prophet (peace and blessings of Allaah be upon him) said: “A woman may be married for four reasons: her wealth, her lineage, her beauty and her religious commitment. Marry the one who is religiously committed, may your hands be rubbed with dust (i.e., may you prosper).” (Narrated by al-Bukhaari, 4802; Muslim, 1466).
Shaykh ‘Abd al-Ghani al-Dahlawi said: Choose from among women those who are religiously committed and righteous, and who are of good descent, for if a woman is of illegitimate descent, this bad characteristic may be passed to her children. Allaah says (interpretation of the meaning):
“The adulterer — fornicator marries not but an adulteress — fornicatress or a Mushrikah; and the adulteress –fornicatress, none marries her except an adulterer — fornicator or a Mushrik”
Rather Islam recommends compatibility for the purpose of harmony and to avoid a person being shamed if he marries into a family that is not compatible.
Sharh Sunan Ibn Maajah, 1/141