Joseph was a pious and sincere servant of God, and for that, Allah turned away from him the evil and indecency:ِ
``.... And so did We, in order to turn away from him the evil and indecency, for, he was of our sincere servants.''
This shows that so long as a man has faith in God and seeks to keep himself sincere and pure, God will not leave him alone and unattended in the hazards and critical conditions. He guards and protects His servants, and delivers them from darkness to light, as a reward of their piety and being faithful.