Because Joseph her husband was faithful to the law, and yet[a] did not want to expose her to public disgrace, he had in mind to divorce her quietly.
Every time I read this passage I am humble by Joseph response to Mary. He finds out his bride to be is pregnant by someone that its not him and his heart was to deal with the issue quietly to avoid disgracing her in public.
I imagine what it will be like if so many if us including myself adapted that principal. Often in pain I can do things impulsively and then regret my actions. I can imagine a whole different relationship with Mary and Joseph had he chosen to rant or embarrassed her publicly. A lot of times I don't realize that they way I feel about someone that hurt me will change as I heal but I do a lot of damage to the relationship when I publicly disgrace the person.
I recall times in my life when I felt hurt by a friend and ranted about and after we worked things out I felt horrible because now I had talked about her or him and caused someone else to view them with critical eyes.
Sadly in our world today there are more ways to disgrace someone publicly specially through media and without even thinking about the damage that can do we rant and say very nasty things about them.
Joseph was going to deal with the issue quietly in spite of how he felt at the moment.
I pray to have that heart when I am hurt to not publicly disgrace someone. I pray to apply Matthew 18:15-17 when I feel hurt by someone.