39:21 But the Lord was with Joseph and shewed him mercy. God despiseth not his prisoners, Psa 69:33. No gates nor bars can shut out his gracious presence from his people. God gave him favour in the sight of the keeper of the prison - God can raise up friends for his people even where they little expect them. The keeper saw that God was with him, and that every thing prospered under his hand, and therefore intrusted him with the management of the affairs of the prison.
39:19-23 Joseph's master believed the accusation. Potiphar, it is likely, chose that prison, because it was the worst; but God designed to open the way to Joseph's honour. Joseph was owned and righted by his God. He was away from all his friends and relations; he had none to help or comfort him; but the Lord was with Joseph, and showed him mercy. Those that have a good conscience in a prison, have a good God there. God gave him favour in the sight of the keeper of the prison; he trusted him to manage the affairs of the prison. A good man will do good wherever he is, and will be a blessing even in bonds and banishment. Let us not forget, through Joseph, to look unto Jesus, who suffered being tempted, yet without sin; who was slandered, and persecuted, and imprisoned, but without cause; who by the cross ascended to the throne. May we be enabled to follow the same path in submitting and in suffering, to the same place of glory.