It's a dynasty, for crying out loud.
noun
noun: dynasty; plural noun: dynasties
a line of hereditary rulers of a country.
The Bible has some historical events, but it isn’t a history book.
And genealogy that mixed real line, with claiming a mythological ancestry, are quite common with ancient genealogy.
That same line of the kings of Judah, go all the way back to the mythological Judah, a son of Israel-Jacob, back to Abraham (more myth), back to Noah (again, more myth), back to Adam (with even more myth), and ultimately back to dust that Adam was transformed from...which (ie dust-to-Adam) is the nothing but myth.
In the gospel of Matthew, its tree started with Abraham, but in the Luke gospel, it goes alway back to Adam and to God. Plus, both trees of Joseph, showed that Joseph have different fathers, with 2 different lines Joseph to David, and those lines with Matthew’s line having go back 27 generations, while Luke’s genealogy has 42 generations.
Now I know it is possible to have a gap of 1, 2 or even 3 generations when comparing two different family trees, but the gap between the 2 gospels, is 15 generations. That not likely possible.
But I know that some people give the explanation that tree given in the Luke gospel was Mary, but it actually stated that Joseph’s father was Heli, not Mary’s.
Mary’s father was never mentioned. And the first time, Christians given the Mary-Heli connection was the early 4th century Eusebius. Did Eusebius have any literary record that explicitly says Heli was really Mary’s father, not Joseph’s father?
The answer to that is, a “No”. Eusebius used fabricated excuses, not any lost record of Mary’s line to David.
Beside that, Mary in the gospel of Luke, made it very explicit that she was related to Elizabeth (Luke 1:36), the mother of John the Baptist, and that Elizabeth was a descendant of Aaron (1:5).
Which would mean Mary was most likely a descendant of Aaron too, not to David or to Judah. Joseph has been referred to as “son of David”, but Mary was never called “daughter of David”. And the story of travel to Bethlehem, stated that Joseph was of the line of David, not Mary.
As I said, the whole Mary being daughter of Heli was made up, with Eusebius first coming up with this idea, but he has nothing to verify his claim about Mary’s alleged line, let alone the identity of her parent.
But the problem isn’t just with Matthew and Luke. There is also the problem with the gospel of Matthew when you compared the lines of 1 & 2 Kings (OT), in which the the gospels are missing 4 generations. I would guess that 3 of omitted names (Ahaziah, Joash & Amaziah) were made in the gospel, because the author want to use the magic number “14 generations”.
As you see, people make up all sort of myths when it concern family trees, even in the gospels.