When Joseph woke up, he did what the angel of the Lord had commanded him and took Mary home as his wife. But he did not consummate their marriage until she gave birth to a son. And he gave him the name Jesus.
(Matthew 1:24–25, NIV)
Joseph and Mary were pledged to be married. Their wedding had not yet taken place when Joseph learned that Mary was pregnant (Matthew 1:18). Matthew doesn’t tell us how Joseph knew; most likely, Mary told him. How did Joseph respond?
Joseph knew the child was not his. According to the Law of Moses, he could have exposed Mary to disgrace, and even to death (Deuteronomy 22:20–21). Facing the potential conflict between justice and mercy, Joseph chose the merciful option of a quiet divorce (Matthew 1:19). Of course, such a ceremony could hardly remain private. As her pregnancy progressed her condition would have been obvious, and probably his own reputation would have been impugned because of their relationship.
A nighttime visit by an angel changed Joseph’s decision. The angel told Joseph that the child he and Mary would raise together was conceived by the Holy Spirit and would be the Savior of the world; He would be Immanuel, God with us.
When Joseph woke he obeyed the word of the Lord through the angel. The righteous Joseph chose to link himself to Mary, his reputation to hers, his destiny to the one he loved. Like Jesus would do to a much greater degree, Joseph condescended to treat Mary with mercy and grace.
Joseph took Mary to be his wife, but they did not consummate their marriage until after Jesus was born, thus preserving her virginity. She conceived her Son as a virgin and gave birth to Him as a virgin. This is what the prophet Isaiah had predicted (Matthew 1:23; see Isaiah 7:14). When the child was born, as His father, Joseph named Him Jesus.
Jesus is the Son of His Father, the Most High God (Luke 1:35). Jesus’s Father is righteous.
Jesus is the son of Joseph, the son of David. Jesus’s earthly father was a righteous man.
Joseph, a righteous man, became a righteous father to the One who is the incarnation of righteousness—the great Son of David, Jesus.