Because Joseph her husband was faithful to the law, and yet did not want to expose her to public disgrace, he had in mind to divorce her quietly. Matthew 1:19
All the evidence points toward Joseph being deeply in love with Mary. He would have been looking forward to marrying her and having a family. Mary’s actions tell us that she was a devout Jew with a sincere faith. Joseph must have been devastated when he learnt Mary was pregnant, knowing he wasn’t the father. How could Mary have done such a thing? Poor Joseph! He was living a life of faithfulness to the law and must have felt deeply betrayed.
It seems he had three choices: he could expose her to public disgrace which he was entitled to do and under the law. This might lead to Mary being stoned, though this was rare at the time. He could divorce her quietly, which only required two witnesses and was a more compassionate alternative for Mary, or he could remain engaged. In his mind this would mean, forgiving Mary for her apparent unfaithfulness, soiling his own good reputation and bring an unknown man’s child into his family line.
Joseph opts to divorce her quietly. His anger didn’t fuel a desire to punish Mary. He planned to act in a way that showed compassion for her and shows us how deeply he cared for her.
When we read the rest of the story we realize how fully convinced Joseph was by the angel since we read in verse 25: “But he did not consummate their marriage until she gave birth to a son.” It was a virgin conception but Joseph ensured it was a virgin birth.
Joseph lived righteously despite his perplexing circumstances, honouring God and being an example to us.Matthew's Gospel