The biblical text says only that Potiphar was furious and imprisoned Joseph. The Targum Pseudo-Jonathan tells us something remarkable the Hebrew leaves unstated. Joseph's master took counsel of the priests, who put him not to death, but delivered him into the house of the bound, where the king's prisoners were bound (Genesis 39:20).
The Aramaic is doing heavy lifting. If a slave had actually attacked the wife of a senior officer of Pharaoh, the standard Egyptian punishment would have been immediate execution. The Targum, redacted in the Land of Israel in the early common era, preserves a tradition: Potiphar did not kill Joseph because when he consulted the priests — the legal and religious authorities of the court — they told him Joseph was innocent. The evidence did not add up. The torn garment was inconsistent. Joseph's reputation in the house was spotless.
Bereshit Rabbah 87 and other midrashim preserve a bolder version: Potiphar himself knew his wife's habits and recognized the falsity of her accusation. The imprisonment, on this reading, is not a verdict but a compromise. Potiphar must be seen to do something or his honor will collapse publicly. A senior officer cannot allow a slave to escape after such an accusation, true or false. So he sends Joseph to the royal prison — the same prison where Pharaoh's own officers are kept — rather than to the executioner.
Notice what this opens. If Joseph had been in an ordinary slaves' prison, he would never have met the chief butler and chief baker (Genesis 40:1-4). The injustice itself is the door to the palace. Divine providence, in the Targum's reading, does not prevent the false accusation; it constrains the punishment just enough that the wronged man ends up in the exact place where he will be needed.
The takeaway is stark and hopeful. Sometimes the injustice we cannot avoid lands us precisely on the road to our own elevation. Joseph goes to prison because he did not sin. He meets the butler in that prison. The butler will eventually speak his name to the king. A false accusation becomes, by the long workings of heaven, the bridge to the chariot of Egypt.