The simple answer to this question is that Jesus was actually the Son of God and the natural heir to the Kingdom by miraculous birth through the virgin girl Mary, of David's line, and Jesus was also the legal heir in the male line of descent from David and Solomon through his adoptive father Joseph. (Luke 1:32, 35; Romans 1:1-4)
The difference in nearly all the names in Luke's genealogy of Jesus as compared with Matthew's is quickly resolved in the fact that Luke traced the line through David's son Nathan, instead of Solomon as did Matthew. (Luke 3:31; Matthew 1:6-7) Luke follows the ancestry of Mary which shows Jesus' natural descent from David. Matthew shows Jesus' legal right to the throne of David by descent from Solomon through Joseph, who was legally Jesus' father. Both signify that Joseph wasn't Jesus' actual father, only his adoptive father and giving him legal right.
Matthew departs from his style when he comes to Jesus, saying: "Jacob became father to Joseph the husband of Mary, of whom Jesus was born, who is called Christ." (Matthew 1:16) He doesn't say that 'Joseph became father to Jesus' but that he was "the husband of Mary, of whom Jesus was born." Luke says that Jesus was actually the Son of God by Mary (Luke 1:32-35) that "Jesus . . . being the son, as the opinion was, of Joseph, son of Heli." Luke 3:23.
Frederic Louis Godet wrote: "This study of the text in detail leads us in this way to admit 1. That the genealogical register of Luke is that of Heli, the grandfather of Jesus; 2. That, this affiliation of Jesus by Heli being expressly opposed to His affiliation by Joseph, the document which he has preserved for us can be nothing else in his view than the genealogy of Jesus through Mary. But why does not Luke name Mary, and why pass immediately from Jesus to His grandfather? Ancient sentiment did not comport with the mention of the mother as the genealogical link. Among the Greeks a man was the son of his father, not of his mother; and among the Jews the adage was: 'Genus matris non vocatur genus ( "The descendant of the mother is not called (her) descendant")' ('Baba bathra,' 110, a)." Commentary on Luke, 1981, p. 129.
Both genealogies show descent from David - through Solomon and through Nathan. (Matthew 1:6; Luke 3:31) They come together again in two persons; Shealtiel and Zerubbabel. Shealtiel was the son of Jeconiah, perhaps by marriage to the daughter of Neri - he was then the "son of Neri." or Neri's son-in-law. It is also possible that Neri had no sons, so that Shealtiel was counted as his "son." ( Compare Matthew 1:12; Luke 3:27; 1 Chronicles 3:17-19)
So, Acts 2:30; 13:23; Romans 1:3; 2 Timothy 2:8; Revelation 22:16 all of which are used by the SAB in support of Joseph being the father of Joseph and the seed of David are accurate in that Joseph was through David's line and legal father to Jesus.
Hebrews 2:16 which refers to Jesus as seed of Abraham refers to the covenant God had with Abraham, which was for a "seed" which many nations would bless themselves. (Genesis 22:17-18; Galatians 3:8) The Jews were all of the seed of Abraham (John 8:39; Matthew 3:9) but they rejected it when they rejected the Messiah. Even in Genesis 22:17-18 it mentions Abraham's seed as being a blessing to all the nations. A spiritual seed that would surpass the fleshly inheritance of the people of Israel.
Matthew 1:8 and Luke 1:31-35 is given as a contradiction but Mary was from the Davidic line and Joseph was Jesus' legal father, so there is no contradiction.
At Matthew 22:45 and Mark 12:35-37 Jesus quotes David in Psalm 110. Jesus never denied that he was a descendant of David, he only points out something the Pharisees were not aware of. Jesus existed in heaven as God's first born only begotten son before the earth was made and before Abraham. (John 1:1; 8:58)
Explanation Of Difficulties in the Genealogies of Matthew and Luke
The first chapter of Matthew the genealogy of Jesus runs from Abraham forward. In Luke chapter 3 the genealogy goes back to "Adam son of God." Part of Jesus genealogy also appears at 1 Chronicles chapters 1 - 3, running from Adam through Solomon and Zerubbabel. The books of Genesis and Ruth combined give the line from Adam to David.
The latter three lists - Genesis/Ruth, 1 Chronicles and Luke - agree fully from Adam to Arpachshad, with minor differences on certain names such as Kenan, which is "Cainan" at Luke 3:37. The Chronicles and Genesis/Ruth lists agree down to David while another "Cainan" is found in Luke's account between Arpachshad and Shelah. (Luke 3:35-36)
From Solomon to Zerubbabel the Chronicles record and Matthew agree though Matthew omits some names. One needs to address these as well as the differences in Luke's account from David to Jesus.
Genealogy involved private family records in addition to the public records of genealogies which chroniclers, such as Ezra, for example, had access to when they compiled their lists. To the registers that existed in the first century up until 70 C.E. the matter of the descent of the Messiah from Abraham through David was very important.
Matthew and Luke no doubt consulted these genealogical tables.
The question is why does Matthew leave out some names that are contained in the listing of other chroniclers? For one thing it is not necessary to name every link in the line of descent. Ezra, for example, in proving his priestly lineage, at Ezra 7:1-5, left out several names that were listed at 1 Chronicles 6:1-15. Matthew seems to have copied from the public register - leaving out some names not needed to prove the descent of Jesus from Abraham and David. Access of the Hebrew Scriptures would have likely been used as well. (Ruth 4:12, 18-22 and Matthew 1:3-6)
Both the lists made by Matthew and Luke would have been publicly recognized by the Jews of that time as authentic. The Pharisees as well as the Sadducees - bitter enemies of Christianity didn't challenge these genealogies. They could have done so up until 70 C.E. when the records were destroyed in the destruction of Jerusalem.
Problems in Matthew's Genealogy?
Matthew divides the genealogy from Abraham to Jesus into three sections of 14 generations each. There is a name count of 41 rather than 42. By taking Abraham to David, 14 names, then using David as the starting name for the second 14, with Josiah as the last and finally by heading the third series of 14 names with Jeconiah (Jehoiachin) and ending with Jesus. Matthew repeats the name David as the last of the first 14 names and as the first of the next 14. Then he repeats the expression "the deportation to Babylon," which he links with Josiah and his sons. (Matthew 1:17)
There is an omission of three kings of David's line between Jehoram and Uzziah (Azariah) because Jehoram married wicked Athaliah of the house of Ahab, the daughter of Jezebel bringing this God condemned strain into the line of the kings of Judah. (1 Kings 21:20-26 / 2 Kings 8:25-27) Matthew named Jehoram as first in this wicked alliance, but left out the next three kings to the fourth generation - Ahaziah, Jehoash, and Amaziah.
Where Matthew indicates that Zerubbabel is the son of Shealtiel (Matthew 1:12) it coincides with other references (Ezra 3:2; Nehemiah 12:1; Hagai 1:14; Luke 3:27) but at 1 Chronicles 3:19 Zerubbabel is listed as the son of Pedaiah. This is because Zarubbabel was the natural son of Pedaiah and the legal son of Shealtiel by brother-in-law marriage or possibly after Zerubbabel's father Pedaiah died Zerubbabel was brought up by Shealtiel as his son and so legally recognized as the son of Shealtiel.
Problems With Lukes Genealogy?
Available manuscript copies of Luke list a second "Cainan" between Arpachshad (Arphaxad) and Shelah. (Luke 3:35 Compare Genesis 10:24 / 11:12; 1 Chronicles 1:18, 24) Most scholars take it to be a copyist's error. "Cainan" is not found in this position in the Hebrew genealogical listings in the Hebrew or Samaritan texts, nor in any of the Targums or versions except the Septuagint. It doesn't seem to be in earlier copies of the Septuagint because Josephus - who almost always uses the Septuagint - lists Seles (Shelah) next as the son of Arphaxades (Arpachshad) - (Jewish Antiquities, I, 146 [vi, 4]) Africanus, Irenaeus, Jerome and Eusebius all rejected "Cainan" in Luke's account as an interpolation.
Bible Lists of Jesus' Genealogy
Genesis And Ruth - Adam, Seth, Enosh, Kenan, Mahalalel, Jered, Enoch, Methuselah, Lamech, Noah, Shem, Arpachshad, Shelah, Eber, Peleg, Reu, Serug, Nahor, Terah, Abram (Abraham), Isaac, Jacob (Israel), Judan (and Tamar), Perez, Hezron, Ram, Amminadab, Nahshon, Salmon, Boaz (and Ruth), Obed, Jesse, David.
1 Chronicles chapters 1, 2, 3. - Adam, Seth, Enosh, Kenan, Mahalalel, Jared, Enoch, Methuselah, Lamech, Noah, Shem, Arpachshad, Shelah, Eber, Peleg, Reu, Serug, Nahor, Terah, Abraham, Isaac, Jacob, Judah, Perez, Hezron, Ram, Amminadab, Nahshon, Salmon (Salma, 1 Chronicles 2:11), Boaz, Obed, Jesse, David, Solomon, Rehoboam, Abijah, Asa, Jehoshaphat, Jehoram, Ahaziah, Jehoash, Amaziah, Azariah (Uzziah), Jotham, Ahaz, Hezekiah, Amon, Josiah, Jehoiakim, Jeconiah (Jehoiachin), Shealtiel (Pedaiah) (See Footnote # 1), Zerubbabel (see Footnote # 2).
Matthew Chapter 1 - Abraham, Isaac, Jacob, Judah (and Tamur), Perez, Hezron, Ram, Amminadab, Nahshon, Salmon (and Salmon Rahab), Boaz (and Ruth), Obed, Jesse, David (and Bath-sheba), Solomon, Rehoboam, Abijah, Asa, Jehoshaphat, Jehoram, Uzziah (Azariah), Jotham, Ahaz, Hezekia, Manasseh, Amon, Josiah, Jeconiah, Shealtiel, Zerubbabel, Abiud, Eliakim, Azor, Zadok, Achim, Eliud, Eleazar, Matthan, Jacob, Jusus (foster son).
Luke chapter 3 - Adam, Seth, Enosh, Cainan, Mahalaleel, Jared, Enoch, Methuselah, Lamech, Noah, Shem, Arpachshad, Cainan, Shelah, Eber, Peleg, Reu, Serug, Nahor, Terah, Abraham, Isaac, Jacob, Judah, Perez, Hezron, Arni (Ram?), Amminadab, Nahshon, Boaz, Obed, Jesse, David, Nathan (See Footnote # 3), Mattatha, Menna, Melea, Eliakim, Jonam, Joseph, Judas, Symeon, Levi, Matthat, Jorim, Eliezer, Jesus, Er, Elmadam, Cosam, Addi, Melchi, Neri, Shealtiel (See Footnote # 4), Zerubbabel, Rhesa, Joanan, Joda, Josech, Semein, Mattathias, Maath, Naggai, Esli, Nahum, Amos, Mattathias, Joseph, Jannai, Melchi, Levi, Matthat, Heli (father of Mary), Joseph (Heli's son-in-law), Jesus (Mary's son).
Footnotes
Footnote # 1. Zerubbabel evidently was the natural son of Pedaiah and the legal son of Shealtiel by brother-in-law marriage; or he was brought up by Shealtiel after his father Pedaiahs death and became legally recognized as the son of Shealtiel (1 Chronicles 3:17-19 / Ezra 3:2 / Luke 3:27).
Footnote # 2. The lines meet in Shealtiel and Zerubbabel, afterward diverging. This divergence could have been through two different descendants of Zerubbabel, or Rhesa or Abiud could have been a son-in-law.
Footnote # 3. At Nathan, Luke begins reckoning the genealogy through Jesus maternal line, while Matthew continues with the paternal line.
Footnote #4. Shealtiel the son of Jeconiah possibly was the son-in-law of Neri. (1 Chronicles 3:17 / Luke 3:2