Joseph had three choices. He could:
1. Expose her pregnancy publicly. This would bring about much dishonor, gossip, and scandal. Did you ever notice the words Gospel and Gossip are right next to each other in your Bible concordance? One tells the truth of God, the other tells half-truths or lies. If Joseph chose to "expose" her it would fall under the sin of gossip. We are told in Titus 3:1-2, Remind the people to be subject to rulers and authorities, to be obedient, to be ready to do whatever is good, 2 to slander no one, to be peaceable and considerate, and always to be gentle toward everyone.
3. Marry her and raise the child as his own. Right answer!
Joseph responded in kind to the words of Jesus 30 years later when He said, Blessed are those who hunger and thirst for righteousness, for they will be filled. Blessed are the merciful, for they will be shown mercy. Blessed are the pure in heart, for they will see God. Blessed are the peacemakers, for they will be called children of God. - Matthew 5:6-9
Be wise today and always - seek God's blessing in your choices.