When Joseph woke from his dream, he willingly obeyed God and took Mary home to be his wife, in spite of the public humiliation he would face. Perhaps this noble quality is one of the reasons God chose him to be the Messiah's earthly father.
At that time, Caesar Augustus decreed that a census be taken, and every person in the entire Roman world had to go to his own town to register. Joseph, being of the line of David, was required to go to Bethlehem to register with Mary. While in Bethlehem, Mary gave birth to Jesus. Probably due to the census, the inn was too crowded, and Mary gave birth in a crude stable. She wrapped the baby in cloths and placed him in a manger.