If Mary and Joseph lived in Nazareth, how did it happen that baby Jesus was born in Bethlehem? Read Luke 2:1-5.
Old Testament prophecies had to be fulfilled. The prophet Micah (See Micah 5:2) foretold that the ruler of Israel will come from Bethlehem. This might be an insurmountable problem for people, but not for God.
The Roman emperor sent out a command that all people must return to the towns of their ancestors for a census (some Bible translations say they went to be “taxed” which may well have been a key component of the census taking). Since Joseph was descended from King David, Mary and Joseph were required to travel to Bethlehem, the city of David, for this census. It is worth mentioning that Mary too was a descendant of King David.
Again, Mary had a long trip ahead of her - close to 100 miles. This time Mary was “great with child” and very close to her delivery date, but she had to complete this journey to fulfill the law. The last part of the journey was a long steep climb that would be difficult with or without the help of a donkey. The Bible doesn’t say if Mary and Joseph even had a donkey, so they may have walked all the way.
For younger children The First Christmas, by Janice D. Green, illustrated by Violet Vandor.