Joseph was a righteous man who had cultivated a reputation for godliness in his community. Then word spread across the community that Mary, the woman to whom he was engaged, was expecting a child. There would be many who would assume the worst of this apparently scandalous situation. Joseph probably experienced gossip from some, ostracism from others. Yet he was a man of integrity, aware that God knew the truth of his relationship with Mary.
At times, God will be the only witness to your righteous behavior. Sometimes God is the only one who will understand your motives. Sometimes you will do all you know God has asked you to do, only to face ridicule from others. At such times all you can do is maintain your integrity, trusting that God always keeps His eyes on you. God looks favorably upon those who walk with integrity, doing what they know is right, regardless of how others perceive their actions.
The most important thing is not that people know the truth. The most important thing is that you are a person of integrity before God. When no one seems to understand why you have done something or when others question whether you have done all you should have done, your confidence should not be in the hope of vindication in the eyes of others. It should be in the knowledge that God keeps you in His sight. If you have this confidence, it will be enough to sustain you.