Now the birth of Jesus Christ, the Messiah, happened in this miraculous way: When His mother Mary had been pledged in a legally binding betrothal to Joseph—a commitment as binding as marriage itself—before they came together in physical union as husband and wife, she was found to be with child, pregnant through the supernatural work of the Holy Spirit, not through any human father.
So Joseph, her husband and betrothed—being a righteous and just man who sought to obey God's Law, and not willing to expose her publicly to shame and potential stoning for suspected adultery—intended to divorce her and send her away secretly and quietly, to protect her from public disgrace.