Is it the result of some poetic refusal of inheritance along the line somewhere, like Aragorn in LotR? Or is it just that the when Romans came to town they screwed up the local governmental structure? Or something else?
I'm not entirely sure that this is the proper place to ask this, but i figured it's worth a shot.
What the other poster outlined is true; it's also possible that the inheritance is just ficticious somewhere. Setting aside religious attachments to the gospels, devising a illustrious lineage for a prominent individual is a relatively common premodern historiographical trope. For example, many medieval histories of Britain claimed that the English kings were descendants of Aeneas; while this assertion is clearly now untrue it did link the kings to a famous hero who was also regarded as a founder of other royal lines. Incidentally, a line of descendants or putative descendants of King David did retain prominence in late antiquity and into the Islamic period as the resh galuta or Exiliarchs. It was mainly an honorary position for most of its later history with some internal power in the Jewish community, but a very highly honored one.
In addition to what the other commenters pointed out, the Davidic line hadn't ruled in Judah in nearly 600 years by the traditional date of Jesus' birth. King Zedekiah, the last Davidic King of Judah, was overthrown and taken prisoner by Nebuchadnezzar of Babylon in the traditional date of 586 BCE.
Neither the Hasmonean Dynasty (a dynasty claiming its origins in the priestly caste) nor the Herodian Dynasty (of Idumean extraction and imposed by the Romans) were Davidic, and the Davidic line hadn't been in power for 600 years. A person who claimed to be a descendant of the House of David would be just as time-removed and obscure as the people who today claim to be the Yorkist heirs of the English throne.
According to the Bible (which isn't too strongly regarded as a historical source, yet does offer a logical explanation to your question), King David had eighteen sons. His successor, King Solomon, had (again, according to the Bible), around a thousand wives and concubines, and assuming that Joseph descended from either of those two, in the nearly nine centuries between King David's rule and the birth of Jesus, it would be likely that David's progeny would have been spread thin throughout the successive generations, and therefore there would be many who could claim descent from the king, despite coming from less noble circumstances.