In order to fulfill the prophecy in Micah that the Messiah would be born in Bethlehem, Mary needed to travel there. God directed the Roman government to conduct a census that required Joseph to pack up with his whole family there. It’s interesting that Mary and Joseph still aren’t married yet, as v. 5 calls her “his betrothed”. Popular imagery always depicts this journey as Joseph leading Mary on a donkey, by themselves. But in reality they would have been too poor for even a pack animal, and both their extended families would have needed to travel to Bethlehem at the same time since they are descended from King David too.
The Greek word for “inn” in the first century doesn’t have the connotation of a professional room renter. It’s really just a general term for “place you stay”. Both Mary and Joseph probably had relatives living in Bethlehem that they stayed with. Have you ever had a Christmas or other event where all your cousins were under one roof for an extended stay? Every room in the house will have temporary beds set up, with as many people together as you can fit. Now add a birth to the mix. It was also common in that time for livestock to live in the same buildings as people, especially when you can’t afford a separate barn or stable. There probably was literally no more room for a tiny baby to sleep in, so they put him in a food trough until they could figure out something else.
You are sovereign over the nations, and no detail escapes Your notice.