Matthew and Luke both claim that Jesus was born of a virgin. However, the details of their stories are quite different. What to make of that?
Matthew has written his story of Jesus from a particular perspective. His story begins with a genealogy. In the genealogy he describes three periods with fourteen fathers begetting sons. The three periods are Abraham to David, David to the Exile (when Jerusalem was over run) and the exile to Jesus. By highlighting these key moments in history, Matthew is particularly emphasizing how God saves (Jesus=Jeshua=Yahweh Saves) His people. Abraham and David both received important promises from God relating to God's gift of salvation to the world and to His people.
Matthew includes several woman, each one a person who was a foreigner or whose motherhood was the result of unusual circumstances. This is a preview of Mary's pregnancy. The foreigner theme is also a key issue for Matthew, who seems to be writing, in part, to explain why the Gentiles believe in Jesus while many Jews reject Him. Scholars have noted that the numerical value of the name DAVID (in Hebrew each letter is also a number) is fourteen. Are the three sets of fourteen fathers also a reference to David? We do not know. It would be lovely if Matthew had included a "behind the scenes of writing the Gospel" in his work. We do know that Luke has a different genealogy. It goes back in time all the way to Adam. It does not include some of the same names. But he is making his point as well, which echos throughout his gospel.
Genealogies for many of us are repetitive and boring. This was not the case for the biblical writers. The names listed are often people about whom we know things. Someone who knows the bible knows who many of these people are. The woman especially (e.g., Bathsheba is an adultress, Rahab a prostitute, etc) are important examples of how someone can make mistakes in their life yet still help God's plan along. (It is also a remnider that woman may not be appreciated in ancient culture as much as men, but God respects them)We are the result of our heritage. Choices made long ago impact us today. God is seceretly at work through us saving the world. In Jesus we see the central act of God's activity. But it is a consolation to know that Jesus comes from some questionable predecessors.