The Birth of Jesus:While Mary was still engaged to Joseph, she miraculously became pregnant through the Holy Spirit, as foretold to her by the angel. When Mary told Joseph she was pregnant, he had every right to feel disgraced. He knew the child was not his own, and Mary's apparent unfaithfulness carried a grave social stigma. Joseph not only had the right to divorce Mary, under Jewish law she could be put to death by stoning.
Although Joseph's initial reaction was to break the engagement, the appropriate thing for a righteous man to do, he treated Mary with extreme kindness. He did not want to cause her further shame, so he decided to act quietly. But God sent an angel to Joseph in a dream to verify Mary's story and reassure him that his marriage to her was God's will. The angel explained that the child within Mary was conceived by the Holy Spirit, that his name would be Jesus and that he was the Messiah, God with us.
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.
Joseph too must have wondered in awe as he remembered the words found in Isaiah 7:14, "Therefore the Lord himself will give you a sign: The virgin will be with child and will give birth to a son, and will call him Immanuel." (NIV)
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.