The book of Matthew opens with a stylized genealogy of Jesus of Nazareth (Matthew 1:1-17). Matthew presents the list in three parts—from Abraham to David, from David to the captivity in Babylon, and from the captivity to Christ—each with fourteen generations. The genealogy is perfectly correct in every way.
What Matthew records is not Christ's biological ancestry but His legal one. Verse 16 gives the proof: "And Jacob begot Joseph the husband of Mary, of whom was born Jesus who is called Christ." It is Joseph's family tree! Remember, Christ was not begotten of Joseph but of the Holy Spirit. Legally, Christ could trace his ancestry back to David through his "father" Joseph, though He had not one drop of Joseph's—or Jehoiachin's—blood!
We must remember a major purpose of Matthew's gospel: to present Jesus of Nazareth as the Messiah to the Jews. The Jews were, and still are, very particular about genealogies. Anyone claiming to be the Messiah would have to present a bona fide, airtight ancestry back to David if he were to be taken seriously (see Psalm 110:1; Isaiah 9:6-7; Jeremiah 23:5-6; etc.). Matthew does just that in introducing Jesus in the first verses of his book.
Thus, Jesus, untainted by Jehoiachin's curse (Jeremiah 22:30), has a legal claim to the throne of David through His stepfather, Joseph. Such a thing was legally acceptable under Jewish law.
Richard T. Ritenbaugh