What does Luke 2:5 mean?
The registration required is one ordered by Augustus, then the Emperor of Rome (Luke 2:1). Part of this requirement is for people to go to their ancestral hometowns (Luke 2:3). Since Joseph's lineage is through David, his destination is Bethlehem (1 Samuel 17:12; Luke 2:4). Scholars are divided on whether this travelling and registration happened when Quirinius was in control of Syria (Luke 2:2), or if the registration happened before an actual taxation was levied later, possibly after the death of Herod (Matthew 2:19).Joseph's relationship to Mary is "betrothal," which is only vaguely like modern "engagement." Betrothal in the ancient world was more like "pre-marriage." It required a divorce to break, but the couple did not live together or consummate the relationship. Since Joseph and Mary are not truly married, it would have been unusual for them to travel together. In this case, however, Mary is already pregnant, with a baby miraculously conceived by the Holy Spirit (Luke 1:30–33). Since she was close to giving birth (Luke 2:6), it seems it made the most sense for her to be with her promised husband when it happened.
This will also fulfill the prophecy that Messiah would be born in Bethlehem (Micah 5:2).