Micah the prophet had revealed that Christ would be born in Bethlehem (Micah 5:2). Joseph and Mary lived in Nazareth. God miraculously moved an empire to fulfill His Word concerning the place of Christ's birth.
Ten years previous to the birth of Christ, the Roman Government passed a tax law and then did not enforce it. After ten years (right on time), the law was enforced and every man was required to return to the city of his family to pay his taxes. This provided both a census and a taxation in one operation. Joseph and Mary were therefore obligated to leave their home in Nazareth and go to Bethlehem because he was of the house and lineage of David. The mighty Roman Empire unwittingly became a partner in the precision timing of the moment of the ages -- the moment we always acknowledge whenever we date a letter, check or legal document.
Our God can control the great and small forces of life. If this were not true it would be impossible for Him to fulfill His promise to cause all things to work together for good for those who love Him and are the called according to His purpose (Romans 8:28).
Had you been looking down on the situation before the trek to Bethlehem by Joseph and Mary, you might have said, "There is no way to work this out. Christ will be born in the wrong town." But God knew how to fulfill His Word and solve the problem. Look at all your problems in that same light and leave the solutions to Him!