This is part of a series of questions regarding the Braisa in Avos d'Rebbi Nassan 16:2 that lists how Yosef HaTzaddik, R' Tzadok, R' Akiva, and R' Eliezer HaGadol were able to overcome their inclination to sin.
In telling over Yosef's story, the Braisa says that Potiphar's wife would threaten him daily, and Yosef would continue ignoring her, quoting a passuk in Tehillim 146 to illustrate his emunah.
She said to him, "I will lock you in prison [if you don't sin]." He said to her, "HaShem releases the bound" (v. 7).
She said to him, "I will gouge out your eyes." He said to her, "HaShem gives sight to the blind" (ibid.).
She said to him, "I will make you wicked." He said to her, "Hashem loves the righteous" (v. 8).
She said to him, "I will make you a non-Jew." He said to her, "HaShem guards the strangers" (v. 9).
The Binyan Yehoshua explains that "I will make you wicked" means I will slander you such that everyone believes you are wicked. Since he was righteous, though, HaShem would protect him from her slander.
Well, ultimately that's what she did, and we know where that landed him. So what happened to "HaShem loves the righteous"?