According to generally accepted Christian tradition, it was because there was a Roman census and Joseph had to return to his home town. A biblical passage from Luke (Chapter 2) supports this.
- 1 And it came to pass in those days, that there went out a decree from Caesar Augustus that all the world should be taxed.
- 2 And this taxing was first made when Cyrenius was governor of Syria.)
- 3 And all went to be taxed, every one into his own city.
- 4 And Joseph also went up from Galilee, out of the city of Nazareth, into Judaea, unto the city of David, which is called Bethlehem; (because he was of the house and lineage of David:)
- 5 To be taxed with Mary his espoused wife, being great with child.
- 6 And so it was, that, while they were there, the days were accomplished that she should be delivered.
Unfortunately this is contradicted by a few other issues. The Gospel of Matthew seems to suggest that Mary and Joseph were actually living in Bethlehem to begin with, and did not travel at all. Luke also refers to Cyrenius being the governor, whereas Matthew says it was Herod (who is known to have died in 4BC). Matthew also makes reference to Herod ordering the death of all boys under ywo years of age, however the is no historical corroboration to support this.
As a result, many scholars see the nativity stories either as completely fictional accounts, or at least constructed from traditions which predate the Gospels.