Agnostics and atheists often point to the differences in the genealogies of Matthew and Luke as a reason not to trust scripture. However, it actually points to the superior wisdom of God. Both are correct because they trace the ancestors of Christ through his respective earthly parents. God had a purpose for it that is really ingenious.
First, it is important to note that in Matthew 1:12 it refers to Jeconiah, who is sometimes referred to as Coniah or Jehoiachin in the Old Testament. Jeremiah 22:28-30 reveals a curse that God placed on Jeconiah, which resulted in him and his descendants being excluded from the throne forevermore.
Second, notice that this genealogy leads to Joseph – who is called the “husband of Mary, of whom was born Jesus who is called Christ” in Matthew 1:16. The words show that Mary is the mother, but Joseph is not the biological father. This biological path stops at Joseph.
Third, this is important because Joseph is in the lineage of Jeconiah and therefore subject to the curse. If Joseph were the biological father of Jesus, then Jesus would have no right to the throne. However, as the adopted son, Jesus would have avoided the impact of the curse and have the royal right to the throne.
Fourth, Luke’s genealogy of Mary actually places Jesus as a descendant of Nathan who was Solomon’s older brother. If there were some reason that Solomon’s line could not continue, Nathan would be able to claim legal right to the throne as the elder brother.
In other words, the two genealogies are brought together in Christ, who is the only one capable of claiming the throne and thus the ability to be the Messiah.
Note the words of Donald Grey Barnhouse:
“But when God the Holy Spirit begat the Lord Jesus in the womb of the virgin without any use of a human father, the child that was born was the seed of David according to the flesh. And when Joseph married Mary and took the unborn child under his protective care, giving him the title that had come down to him through his ancestor Solomon, the Lord Jesus became the legal Messiah, the royal Messiah, the uncursed Messiah, the true Messiah, the only possible Messiah. The lines are exhausted. Any man that ever comes into this world professing to fulfill the conditions will be a liar and the child of the devil.”1
There are other theories, but this one best fits the scriptures.
1 Donald Grey Barnhouse – Romans Vol. 1 – “Man’s Ruin” p47. Also quoted in James Montgomery Boice – The Gospel of Matthew Vol. 1 – p18.