Most people only know about Vishnu's incarnation Rama, who was a king of the solar dynasty. But many generations before Rama, Vishnu incarnated as another solar dynasty king, known as Mandhata (AKA Mandhatri). The story of Mandhata's birth is told in numerous Hindu scriptures, including this chapter of the Vana Parva of the Mahabharata, this chapter of the Vishnu Purana, and this chapter of the Srimad Bhagavatam. It goes roughly as follows.
There was once a king of Ayodhya named Yuvanshva who had numerous wives but no children, so he conducted a Yagna to have a son. The priests gave him a pot of water and told him to instruct one of his wives to drink it in order to become pregnabtt. But in the middle of the night, Yuvanshva was thirsty and accidentally drank the water himself. So despite being a man, he became pregnant! The Ashwini Kumaras, gods associated with medicine, helped deliver the child, named Mandhata, and then Indra provided it with milk from his finger. Mandhata grew up to be a great emperor who apparently conquered the three worlds. He had numerous daughters, who married the sage Saubhari, and he had illustrious sons like Muchukunda and Ambarisha (whom I discuss here.)
But my question is, what is the purpose of Vishnu incarnating as Mandhata? As I discuss in this answer, the Matsya Purana describes various incarnations of Vishnu in the present Vaivasvata Manvantara, and here is all it says about the Mandhata incarnation:
The fifth incarnation was that of the world-Emperor, Mandhatri, which took place in the fifteenth Treta, when Uttanga was the officiating priest.
This excerpt from the Prabhasa Khanda of the Skanda Purana says the same thing:
The fifth incarnation was in the fifteenth Treta Yuga. He was Mandhata, the emperor, along with Uthathya (as preceptor).
So was the purpose of this incarnation simply to become emperor of the world, or was there more to it than that? I first heard about Mandhata when I was a little kid, while reading Devdutt Pattanaik's book "Vishnu: an Introduction" (which I recommend if you want a good basic understanding of things). Pattanaik claims that Mandhata was the first king to propagate the system of Varnashrama Dharma, or the system of castes and stages of life. Pattanaik is known to take artistic license, though, so is there any scriptural basis for that?