Yosef refused the advances of Eishes Potifar, "V'lo shama eileha lishkav etzlah l'heyos ima." (39:10) The Midrash darshens the double-language of the pasuk to mean that Yosef not only refused to have relations with Eishes Potifar, but he even refused to lie in the same bed as her (lishkav etzlah), despite prophetically knowing that he was destined to join her in olam haba (l'heyos ima).
The Koznitzer Maggid asks what the chiddush of this Midrash is. Obviously Yosef haTzadik would avoid even being in the same bed as her as Eishes Potifar. Would we dream otherwise?
A person grows from each challenge faced and each test overcome. Kal v’chomer this is true of a tzadik like Yosef. Each time he faced Eishes Potiphar and resisted her advances he became spiritually stronger. Eishes Potiphar therefore offered Yosef what seemed like a reasonable suggestion – instead of running away from her, increase the temptation and test by drawing closer, by lying next to her. How much greater schar would be from withstanding such a test – it would guarantee both of them a place in olam ha’ba!
This was the trap that the Midrash is teaching us that Yosef did not fall prey to. Yosef refused to lie next to Eishes Potifar even for the sake of proving that he could resist her and thereby gain additional schar. Given the choice, it's always better to avoid a difficult situation rather than prove one's ability to overcome the challenge. Tempting fate is far too great a risk, no matter what the potential benefit may be.