"Then Joseph her husband, being a just man, and not willing to make her a publick example, was minded to put her away privily." (Matthew 1: 19)
Because Joseph was a righteous man, he did not want to expose Mary as unworthy or sinful on account of the fact that she was pregnant.
Righteousness is all about grace, and being gracious:
"For if by one man's offence death reigned by one; much more they which receive abundance of grace and of the gift of righteousness shall reign in life by one, Jesus Christ." (Romans 5: 17)
Notice that the abundance of grace comes before the gift of righteousness.
Righteousness guarantees us protection from hatred and shame:
"7No weapon that is formed against thee shall prosper; and every tongue that shall rise against thee in judgment thou shalt condemn. This is the heritage of the servants of the LORD, and their righteousness is of me, saith the LORD." (Isaiah 54: 17)
Righteous people do not shame others publically, but rather seek to restore them privately:
"1Brethren, if a man be overtaken in a fault, ye which are spiritual, restore such an one in the spirit of meekness; considering thyself, lest thou also be tempted." (Galatians 6: 1)
Jesus explained to His disciples during His earthly ministry the importance of rebuking privately before confronting people publically:
"15Moreover if thy brother shall trespass against thee, go and tell him his fault between thee and him alone: if he shall hear thee, thou hast gained thy brother. 16But if he will not hear thee, then take with thee one or two more, that in the mouth of two or three witnesses every word may be established. 17And if he shall neglect to hear them, tell it unto the church: but if he neglect to hear the church, let him be unto thee as an heathen man and a publican. 18Verily I say unto you, Whatsoever ye shall bind on earth shall be bound in heaven: and whatsoever ye shall loose on earth shall be loosed in heaven." (Matthew 18: 15-18)
Because we have been made the righteousness of God in Christ, we do not go out of our way to shame others, since He has already seated us in heavenly places (Ephesians 2: 4-6). Instead, just as Joseph was declared righteous and the rightful husband of Mary regardless of what he did, so too we remind our fellow believers who they are in Christ:
"15Know ye not that your bodies are the members of Christ? shall I then take the members of Christ, and make them the members of an harlot? God forbid. 16What? know ye not that he which is joined to an harlot is one body? for two, saith he, shall be one flesh. 17But he that is joined unto the Lord is one spirit." (1 Corinthians 6: 15-17)