Why does Matthew in his gospel list the ancestors of Jesus, when they are really those of his stepfather Joseph, with whom he shares no genes?
The purpose of a genealogy for ancient Jews was more complex and rich than to simply demonstrate physical descent. The modern science of genetics, chromosomes and the genetic code were unknown in the ancient world.
But even among us moderns, relationships are set up both by blood, and by marriage. That is to say, two people can be related either by direct physical descent, or “legally” through the marriage of themselves or others in their family. And thus, while Joseph and Jesus shared no physical genes, Joseph's family and Jesus are one through Joseph's marriage to Mary. So, Joseph’s family tree “matters” to us and to those in ancient Israel because, through Joseph and his marriage to Mary, Jesus relates to many others in Israel.
In ancient Israel, genealogies existed to show that one was in fact a member of the nation of Israel. They located them in a particular tribe, and also to show their relationships with others.
These are Matthew’s main purposes; namely, that Jesus belongs to the family of Israel both as a son of Mary, and through his relationship to Joseph, the husband of the Virgin Mary.
Matthew also has other complex purposes in mind in the names he highlights and the way he groups them in patterns of 14, all laid out according to different periods of salvation history. There are also other numerological details too complex to lay out here.
So, as you can see, there is more than a question of physical descent involved in the recitation of ancient genealogies. Human beings relate in more than physical ways, but also through a complex network of relationships we call families, tribes, and nations.
"Building our Catholic faith one question at a time."