Joseph went there because he was a descendant of David.
[ The Birth of Jesus ] At that time Emperor Augustus ordered a census to be taken throughout the Roman Empire. Joseph went from the town of Nazareth in Galilee to the town of Bethlehem in Judea, the birthplace of King David. Joseph went there because he was a descendant of David. He went to register with Mary, who was promised in marriage to him. She was pregnant,
Luke 2:1, 4-5 GNT