Most people
wrongly assume that the "Joseph" referenced in the lineage listed in Matthew 1:1-17 is Mary's husband.
If that were true, i.e. if the Joseph in Matthew 1:16 is assumed to be Mary's husband, then the generational count would be in error, as Joseph and Mary are the same generation. If it's correctly understood that the Joseph in Matthew 1:16 is Joseph of Arimathaea (Mary's uncle and guardian), then the generational count is correct.
Matthew 1:1-17
1:1 The book of the generation of Jesus Christ, the son of David, the son of Abraham.
1:2 Abraham (1) begat Isaac (2); and Isaac begat Jacob (3); and Jacob begat Judah (4) and his brethren;
1:3 And Judah begat Pharez (5) and Zarah of Thamar; and Pharez begat Esrom (6); and Esrom begat Aram (7);
1:4 And Aram begat Aminadab (8); and Aminadab begat Naasson (9); and Naasson begat Salmon (10);
1:5 And Salmon begat Boaz of Rachab (11); and Boaz begat Obed of Ruth (12); and Obed begat Jesse (13);
1:6 And Jesse begat David the king
(14); and
David the king begat Solomon (1) of her [that had been the wife] of Urias;
1:7 And Solomon begat Rehoboam (2); and Rehoboam begat Abia (3); and Abia begat Asa (4);
1:8 And Asa begat Josaphat (5); and Josaphat begat Joram (6); and Joram begat Ozias (7);
1:9 And Ozias begat Joatham (8); and Joatham begat Achaz (9); and Achaz begat Ezekias (10);
1:10 And Ezekias begat Manasses (11); and Manasses begat Amon (12); and Amon begat Josias (13);
1:11 And Josias begat Jechonias
(14) and his brethren (including Zedekiah), about the time they were carried away to Babylon:
1:12 And after they were brought to Babylon, Jechonias begat Salathiel (1); and Salathiel begat Zorobabel (2);
1:13 And Zorobabel begat Abiud (3); and Abiud begat Eliakim (4); and Eliakim begat Azor (5);
1:14 And Azor begat Sadoc (6); and Sadoc begat Achim (7); and Achim begat Eliud (8);
1:15 And Eliud begat Eleazar (9); and Eleazar begat Matthan (10); and Matthan begat Jacob (11);
1:16 And Jacob begat Joseph (12 – of Arimathaea) the uncle and
guardian of Mary (13* – who was from the British Royal family, which is the Royal line of David and she was also from the Levitical line of Amram, who was the father of Moses and Aaron), of whom was born Jesus
(14), who is called Christ (who was therefore eligible to be both King and High-Priest).
1:17 So all the generations from Abraham to David [are]
fourteen generations; and from David until the carrying away into Babylon [are]
fourteen generations; and from the carrying away into Babylon unto Christ [are]
fourteen generations.
*Matthew 1:16 cannot be referring to Joseph, the husband of Mary, because that would leave only 13 generations from the carrying away into Babylon unto Jesus. The Joseph referenced is therefore the uncle and guardian of Mary, which should explain why Joseph of Arimathaea was able to claim the body of Jesus after the crucifixion,
as only a family member could do according to Roman law.
In the English translation of the Peshitta, which is the Aramaic version of the Bible, Matthew 1:16 states that Joseph was
the guardian of Mary,
NOT her husband.
Matthew 1 Peshitta Holy Bible Translated
Logically, Jacob, son of Matthan (in verse 1:15) probably didn't have two sons that were both named Joseph***. If Mary's dad passed away in Mary's youth, then it makes perfect sense that her dad's younger brother –
Joseph of Arimathaea – would have stepped in to be her guardian, i.e. her uncle taking on the roll of her adoptive dad.
***Mary's dad was reportedly Joachim:
JOSEPH OF ARIMATHEA – WHO WAS HE? | The Ensign Message
The lineage of Joseph, Mary's husband, is provided in Luke 3:23-31, to let people know that even though Joseph was
NOT Jesus' biological dad, Joseph was likewise descended from the royal, kingly line of David.
So, in answer to the question in the OP, Jesus was a literal son (descendant) of king David, making Jesus uniquely eligible to be both High-Priest and King (more on that can be provided, if anyone is interested).