Caesar Augustus taxed everyone, so, Mary and Joseph had to make the trip to the city of David, aka Bethlehem-Judah. Then what follows is very interesting.
3 And all went to be taxed, every one into his own city.
4 And Joseph also went up from Galilee, out of the city of Nazareth, into Judaea, unto the city of David, which is called Bethlehem; (because he was of the house and lineage of David:)
5 To be taxed with Mary his espoused wife, being great with child.