Puranjana was ruling over a vast kingdom. But due to his being too much engaged in materialistic activities he was thinking about the wellbeing of his wife at the moment of death. Therefore he became a woman in his next life.
After some time Krishna appeared in the form of a brahamana in front of Vidarbhi (Puranjana) and instructed her how to achieve the goal of life going back home to Godhead.
(Srimad-Bhagavatam 4.28.28)