Yudhisthira was conceived in an unusual way. His mother, Queen Kunti, had in her youth been granted the power to invoke the Devas by Rishi Durvasa. Each god, when invoked, would place a child in her lap. Urged by Pandu to use her invocations, Kunti gave birth to Yudhisthira by invoking the Lord of Righteousness, Dharma. Being Pandu's eldest son, Yudhisthira was the rightful heir to the throne, but this claim was contested by the Dhritarashtra's son, Duryodhana.
Yudhisthira's four younger brothers were Bhima, (born by invoking Vayu); Arjuna, (born by invoking Indra); and the twins Nakula and Sahadeva, (born by invoking the Ashwini Gods). If Karna, the son of Kunti born before her marriage by invoking Surya is counted, Yudhisthira would be the second-eldest of the Pandava brothers.
Yudhisthira was trained in religion, science, administration and military arts by the Kuru preceptors, Kripa and Drona. He was a master of the spear, and a maharatha, capable of combating 10,000 opponents at a time.
Yudhisthira was also known as Bharata (Descendent of the line of Bharata) and Ajatashatru (One Without Enemies).
Yudhisthira's understanding of dharma was distinct from that of other righteous kings. He married Draupadi along with his four brothers, he had Bhima marry an outcast Rakshasi, he termed "prayer" as "poison", he saw an uneventful life with no credit and a belly full of food at the end of the day as happiness, he denounced casteism, saying a Brahmin is known by his actions and not his birth or education--thus portraying a changeable dharma that modifies itself to suit the times.
Due to his piety, Yudhisthira's feet and his chariot did not touch the ground (until his deception of Drona), to symbolize his purity.
Yudhisthira and his brothers were favored by the Kuru elders like Bhishma, Vidura ,Kripa and Drona over Duryodhana and his brothers, the Kauravas, due to their devotion to their elders, pious habits and great aptitude in religion and military skills, and all the necessary qualifications for the greatest of the kshatriya order.
Yudhisthira married the Panchali princess Draupadi, who bore him his son Prativindya.
When the Pandavas came of age, King Dhritarashtra sought to avoid a conflict with his sons, the Kauravas, by giving Yudhisthira half the Kuru kingdom, albeit the lands which were arid, unprosperous and scantily populated, known as Khandavaprastha.
But with the help of Yudhisthira's cousin Krishna, a new city, Indraprastha, was constructed by the Deva architect Viswakarman. The Asura architect Mayasura constructed the Mayasabha, which was the largest regal assembly hall in the world. Yudhisthira was crowned king of Khandavaprastha and Indraprastha. As he governed with absolute piousness, with a strict adherence to duty and service to this people, his kingdom grew prosperous, and people from all over were attracted to it.
Arjuna, Bhima, Nakula and Sahadeva led armies across the four corners of the world to obtain tributes from all kingdoms for Yudhisthira's sacrifice. At his sacrifice, Yudhisthira honored Krishna as the most famous and greatest personality. This incensed Sisupala, who proceeded to hurl several insults at Krishna and the Pandavas for selecting a "cowherd" for the great honor. When Sisupala's transgressions exceed the hundred pardons that Krishna had promised his mother, Krishna summons the sudarshana chakra to behead him. Following which, the yajna is completed successfully.
Yudhisthira was unable to refuse when Duryodhana's maternal uncle Shakuni, challenged him to a game of dice. Thanks to Shakuni's cheating, Yudhisthira lost each throw, eventually gambling away his kingdom, his wealth, his brothers and finally his wife. Owing to the protests of Vidura, Bhishma and Drona, Dhritarashtra returned all these losses. However, Shakuni challenged Yudhisthira one more time, and Yudhisthira once more lost. This time, he, his brothers and his wife were forced to discharge the debt by spending thirteen years in exile, with the condition of anonymity in the last year, in the forest before they could reclaim their kingdom.
Yudhisthira was criticized by Draupadi and Bhima for succumbing to temptation and playing dice, an art he was absolutely unskilled at, making the Pandavas prey to Shakuni and Duryodhana's evil designs. Yudhisthira reproached himself for weakness of mind, but at the time he argued that it was impossible to refuse a challenge of any nature, as he was a kshatriya and obliged to stand by the kshatriya code of honour.
During the thirteen years, he was repeatedly tested for staunch adherence to religious values in face of adversity.
The conditions of the debt required the Pandavas to disguise themselves and not be discovered during the last year of exile. Yudhisthira learned dice play from Narada Muni and assumed the guise of a brahmin courtier and dice player in the Matsya Rajya of king Virata.
Yudhishthira: One's mother is heavier than the earth; one's father is higher than the mountains. The mind is faster than wind and our worries are more numerous than straws.
Dharma: Who is the friend of a traveler? Who is the friend of one who is ill and one who is dying?
Yudhishthira: The friend of a traveler is his companion. The physician is the friend of one who is sick and a dying man's friend is charity.
Dharma: What is that which, when renounced, makes one lovable? What is that which is renounced makes happy and wealthy?
Yudhishthira: Pride, if renounced makes one lovable; by renouncing desire one becomes wealthy; and to renounce avarice is to obtain happiness.
Dharma: What enemy is invincible? What constitutes an incurable disease? What sort of man is noble and what sort is ignoble?
Yudhishthira: Anger is the invincible enemy. Covetousness constitutes a disease that is incurable. He is noble who desires the well-being of all creatures, and he is ignoble who is without mercy.
Dharma: Who is truly happy? What is the greatest wonder? What is the path? And what is the news?
Yudhishthira: He who has no debts is truly happy. Day after day countless people die. Yet the living wish to live forever. O Lord, what can be a greater wonder? Argument leads to no certain conclusion, the Srutis are different from one another; there is not even one Rishi whose opinion can be accepted by all; the truth about Dharma and duty is hid in caves: therefore, that alone is the path along which the great have trod. This world full of ignorance is like a pan. The sun is fire, the days and nights are fuel. The months and the seasons constitute the wooden ladle. Time is the cook that is cooking all creatures in that pan (with such aids); this is the news.
(Source: KM Ganguly Mhabhata Translation )
The plan was set in motion when Bhima killed an elephant named Ashwathama, and loudly proclaimed that Ashwathama was dead. Drona, knowing that only Yudhisthira, with his firm adherence to the truth, could tell him for sure if his son had died, approached Yudhisthira for confirmation. Yudhisthira told him: "Ashwathama has died". Yudhisthira, who could not make himself tell a lie, despite the fact that if Drona continued to fight, the Pandavas and the cause of dharma itself would have been lost, then added: "Praha kunjara ha", which means he is not sure whether elephant or man had died.
Krishna, knowing that Yudhisthira would be unable to lie, had all the warriors beat war-drums and cymbals to make as much noise as possible at the critical moment. The words "Praha kunjara ha" were lost in the tumult and the ruse worked. Drona was disheartened, and laid down his weapons. He was then killed by Dhristadyumna.
Yudhisthira performed the tarpana ritual for the souls of the departed. Upon his return to Hastinapura, he was crowned king of both Indraprastha and Hastinapura.
Out of his piousness, Yudhisthira retained Dhristarashtra as the king of the city of Hastinapura, and offered him complete respect and deference as an elder, despite his misdeeds and the evil of his dead sons.
Upon the onset of the Kali yuga and the departure of Krishna, Yudhisthira and his brothers retired, leaving the throne to their only descendant to survive the war of Kurukshetra, Arjuna's grandson Parikshita. Giving up all their belongings and ties, the Pandavas made their final journey of pilgrimage in the Himalayas.
While climbing the peaks, Draupadi, and each Pandava in reverse order of age, fell to their deaths, dragged down by the weight of their guilt for their sins. Yudhisthira reached the mountain peak, because he was unblemished by sin or untruth.
The true character of Yuddhisthira is revealed at the end of the Mahabharata. On the mountain peak, Indra, King of Gods, arrived to take Yudhisthira to heaven in his Golden Chariot. As Yudhisthira was about to step into the Chariot, the Deva told him to leave behind his companion dog, an unholy creature not worthy of heaven. Yudhisthira stepped back, refusing to leave behind the creature who he had taken under his protection. Indra wondered at him - "You can leave your brothers behind, not arranging proper cremations for them...and you refuse to leave behind a stray dog!"
Yudhisthira replied, "Draupadi and my brothers have left me, not me [them]." And he refused to go to heaven without the dog. At that moment the dog changed into the God Dharma, his father, who was testing him...and Yudhisthira had passed with distinction.
Yudhisthira was carried away on Indra's chariot. On reaching Heaven he did not find either his virtuous brothers or his wife Draupadi. Instead he saw Duryodhana and his evil allies. The Gods told him that his brothers were in Naraka (hell) atoning their little sins, while Duryodhana was in heaven since he died at the blessed place of Kurukshetra.
Yudhisthira loyally went to Naraka (hell) to meet his brothers, but the sights and sounds of gore and blood horrified him. Tempted to flee, he mastered himself and remained after hearing the voices of his beloved brothers and Draupadi...calling out to him, asking him to stay with them in their misery. Yudhisthira decided to remain, ordering the Divine charioteer to return ... preferring to live in hell with good people than in a heaven of evil ones. At that moment the scene changed. This was yet another illusion to test him on the one hand, and on the other hand, to enable him to atone for his sin of using deceit to kill Drona. Indra and Krishna appeared before him and told him that his brothers were already in Heaven, along with his enemies, for earthly virtues and vices don't hold true in heavenly realms. Krishna yet again hailed Yudhisthira for his dharma, and bowed to him, in the final defining moment of the epic where divinity bowed down to humanity.