Matthew and Luke give the genealogy of Jesus. Matthew starts his Gospel with the genealogy of Jesus tracing back from Joseph to David, the famous king of Israel, and then to Abraham, the father of faith (Mt 1:1-17). God had made a covenant with both and had made the promise of a savior of the world from their lineage. So, Matthew’s pre-history of Jesus traces back from the lineage of Joseph, the foster (legal) father of Jesus, to Abraham. Luke gives a different genealogy of Jesus through his mother Mary (Lk 3:23-38). Here the genealogy of Jesus goes back through King David to Adam, the son of God. The first covenant of God with humanity was through Adam. God had promised a savior after the fall of the first parents (Gen 3:15).
Though Joseph was financially poor, he had royal blood as a descendant of King David, and he was married to Mary, who also had the Davidic lineage. God had promised to King David: “I will set up your seed after you, who will come from your body, and I will establish his kingdom” (2 Sam 7:12). The Jews preserved the genealogy of the descendants of David to assure that the Kings of Jews and the Messiah were from this lineage.
Luke presents Mary’s genealogy to prove that Jesus was biologically the son of David (Lk 3:23-38) and Matthew presents Joseph’s genealogy to prove that the legal or adopted father of Jesus was also a son of David (Mt 1:1-17). Joseph, the foster father of Jesus, was a descendant of David’s son Solomon. Mary was a descendant of King David’s son Nathan. So, we have two genealogical accounts of Jesus through the ancestral lines of Joseph by Matthew and of Mary by Luke. These show that Jesus is the “Son of David” from both by blood (Mary) and by legal right (Joseph).
According to Jewish tradition, adopted as well as biological sons could have hereditary rights. Jesus, his mother Mary, and legal father Joseph were all born in Bethlehem, the City and birthplace of David.
The genealogy of Jesus through Mary and Joseph proves he was a descendent of David, through whose lineage the Messiah and the king of Jews had to come. However, his mission was to save all humanity, and he opened his kingdom for all who will repent and accept his gospel. The genetically pure Jews who rejected him could not attain the salvation he gained for humanity through his sacrifice.