The Gospels of Matthew and Luke shows a linage of Jesus through Joseph and shows how he is a descendant of David, because the technical requirement for someone being the Messiah is that he would be a descendant of King David.
It is suggested that, due to the placement of the lineage in Luke, Luke’s intention was more to establish the priesthood of Jesus rather than his royal status (“But to the tribe of Levi he gave no possession: because the Lord the God of Israel himself is their possession” (Joshua 13:33)). Matthew may have intentionally left out names in order to get a certain number of descendents (see
newadvent.org/cathen/06410a.htm for more details on the differences and some difficulties with the differences)
But does it matter?
See Psalm 110:1 and Matthew 22
Therefore, he has every right to the throne regardless of paternity. Jesus is the Son of God, who is King and Lord over all the Earth, and is called King of Kings. God gave David his earthly throne, and He said, “My kingdom is not of this world.”