When Mary became pregnant with Jesus, it was surely a terrible shock to Joseph. Though he and Mary were betrothed, meaning they had given public and binding vows to each other, they had not yet lived together as man and wife. The only logical conclusion Joseph could reach on his own was that Mary was pregnant by another man – in other words, that she had committed adultery.
Proved adultery was punishable with death by stoning under the Mosaic law. The Gospel of Matthew explains that Jospeh was a “righteous man, yet unwilling to expose [Mary]to shame” so he decided to “divorce her quietly.” (Matthew 1:19). This indicates that although Joseph generally respected the law, he did not want to subject Mary to derision, judgment, and possible death. Though we don’t know a lot about the logistics of what it means to divorce someone “quietly” at this time, it presumably means that Joseph intended to dissolve their union with as little fanfare as possible. It’s clear that he had no desire to see her publicly humiliated or put to death for what he believed to be her transgression.
The Gospel of Matthew then explains that an angel came to Joseph in a dream and told him not to be afraid to take Mary into his home, because the child Mary was carrying was not conceived with another man, but through the power of the Holy Spirit. “She will bear a son and you are to name him Jesus, because he will save his people from their sins.” (Matthew 1:21) This heavenly message changes everything, and Joseph takes Mary into his home as initially planned.