Joseph, her fiancé, was a good man and didn't want to shame her publicly, so he decided to break the engagement discreetly.
Compare with other 3 random translations
ASV Matthew 1:19
And Joseph her husband, being a righteous man, and not willing to make her a public example, was minded to put her away privily.
AMP Matthew 1:19
And her [promised] husband Joseph, being a just and upright man and not willing to expose her publicly and to shame and disgrace her, decided to repudiate and dismiss (divorce) her quietly and secretly.
EAS Matthew 1:19
Joseph was a good man. He wanted to do what was right. He did not want her to become ashamed in front of people. So he decided to stop their marriage secretly.