The Gospel According to Luke says that Jesus was born in Bethlehem because his parents had to travel to their place of origin for a census:
1 Now in those days, a decree went out from Caesar Augustus that all the
world should be enrolled. 2 This was the first enrollment made when
Quirinius was governor of Syria. 3 All went to enroll themselves,
everyone to his own city. 4 Joseph also went up from Galilee, out of
the city of Nazareth, into Judea, to David’s city, which is called
Bethlehem, because he was of the house and family of David; 5 to
enroll himself with Mary, who was pledged to be married to him as
wife, being pregnant. -- Luke 2:1-5, World English Bible
Why not just count the people where they were, as we do today?
Are there non-Christian sources that substantiate the existence of such a requirement, or explain its purpose? Are there non-Christian sources that would cast doubt on this account, or reasons to think that it was an invention by a later generation that was concerned with linking Jesus to David?