When Christ was born, there were several prophecies that were fulfilled that He had no control over. One of them was that He would be born in Bethlehem. After David became king, Jerusalem became known as the City of David. Not Bethlehem. But Micah 5:2 prophesied that Jesus would be born in Bethlehem. The Lord caused Caesar Augustus to send out a decree to the entire [Roman] world that all the world should be enrolled. This caused Joseph and Mary to go to Bethlehem
Think of the logistics. God had to have Caesar Augustus send out a degree. The timing had to be such that it would get to Nazareth after Mary became pregnant, and far enough along so that she would give birth in Bethlehem. Too early, and they would have made the trip and gotten back before the birth. Too late and she would have already given birth. All of this had to be coordinated just right. And it was.
Thank you Father for making this work out. We praise You that You are in control.