But the LORD was with Joseph, and showed him mercy, and gave him favor in the sight of the keeper of the prison.
Read Chapter 39
Ambrose of Milan
AD 397
But what wonder if Christ visits those who lie in prison? He reminds us that he himself was shut up in prison in his followers, as you find it written, “I was in prison, and you did not come to me.” Where does God’s mercy not enter in? Joseph found favor of this sort; he who had been shut up in the prison kept the locks of the prison, while the jailer withdrew from his post and entrusted all the prisoners to his power. Consequently Joseph did not suffer from prison but even gave relief to others as well from the calamity of imprisonment.
While his case was unheard, Joseph was thrown into prison as if guilty of a crime, but the Lord did not desert him there. It is not a source of shame for the innocent when they are attacked by false charges and cast into prison because justice is crushed; the Lord visits his own even in prison, and therefore there is more help where the danger is greater. What wonder is it that Christ visits his own who are in prison, when he recalls that he has been locked up in prison in the person of his people? As you have it written: “I was in prison, and you did not come to me.” Where does the divine mercy not penetrate? Joseph found such favor that he who had been shut up in prison rather guarded the bars of the prison.
Keeper. Pererius thinks this was the same Putiphar, who, recognizing the innocence of Joseph, allows him every indulgence in prison; but does not liberate him, for fear of the dishonour and resentment of his wife. (Calmet)
He had before put him in irons. (Psalm civ. 18; Wisdom x. 13.) Joseph here exercises at once the four cardinal virtues. Prudence, in keeping out of the company of his mistress, as the Hebrew express it, ver. 10: "He yielded not to lie with her, or to be in her company. "(Haydock)
Justice, in regard to his master. Fortitude, in bearing with all sorts of hardships, loss of character And Temperance, by refusing to gratify the most violent of all passions, at an age when it is the most insidious and ungovernable. This makes the fathers exclaim, We wonder more at the conduct of Joseph, than at the delivery of the three children from the Babylonian furnace. For, like them, Joseph continues unhurt, and more shining, in the midst of the flames. (St. Chrysostom) (Tirinus)
...
You notice how even when Joseph encountered troubles he had no sense of distress; instead, the creative wisdom of God transformed all his distress. Just as a pearl reveals its peculiar beauty even if someone buries it in the mire, so too virtue, wherever you cast it, reveals its characteristic power, be it in servitude, in prison, in distress or in prosperity. So since, even when cast into prison, he won over the chief jailer and received from him control of everything there, let us see in this case as well how Joseph reveals the force of grace coming his way.