One day, a great sage, Mandavya, was immersed in meditation under the shade of a tree outside his ashram. Suddenly, a band of dacoits entered his ashram to hide the loot from the king’s police, who were pursuing them. When the police reached the ashram, they saw sage Mandavya meditating under a tree in front of it. The head of the policemen asked Mandavya, “Did you see the dacoits passing by?” The sage, who was absorbed in meditation, remained silent. The officer repeated the question, but the sage neither heard nor replied anything. In the meantime, some of the policemen entered the ashram and discovered the stolen loot and the dacoits hiding there.
The finding gave the police officer a false impression that the sage was, in fact, the head of the dacoits in the guise of a sadhu. Thus, he captured sage Mandavya and the dacoits and presented all of them in front of the king’s court. The king was furious that the dacoit had put on the garb of a sage to deceive the world. Without cross-checking or giving a chance to present his case, the king passed the judgment and ordered the wicked criminal, as he thought him, to be impaled. The king’s men impaled Mandavya on a spear.
But such was the powers of the sage that he remained alive by the power of meditation. Other great sages came to him in the form of birds and flew around him. They then asked sage Mandavy how he was in such a terrible situation. Mandavya replied, “Whom shall I blame? I find no one to blame for my misfortune.”
When the king heard that the impaled sage was still alive and surrounded by other sages, he came running to the sage, surprised and frightened. After ordering his men to take the sage down from the impale, the king prostrated at his feet and prayed for forgiveness. Mandavya was not angry with the king; he went straight to Yamraj, also known as Dharmaraj since he is the divine dispenser of justice, and asked, “What crime have I committed to deserve this torture?” Dharmraj humbly replied, “O sage, you have tortured birds and bees. Are you not aware that all deeds, good or bad, however small, inevitably produce their results, good or evil?”
स्वल्पमेव यथा दत्तं दानं बहुगुणं भवेत् । अधर्म एवं विप्रर्षे बहुदुःखफलप्रदः
svalpameva yathā dattaṁ dānaṁ bahuguṇaṁ bhavet
adharma evaṁ viprarṣe bahuduḥkhaphalapradāḥ
"Small acts of charity (dāna) given with a pure heart can result in abundant merits and virtues while engaging in unrighteousness (adharma) even in small ways can lead to significant negative consequences and suffering."
Mandavya was surprised at this reply and asked, “When did I commit this offence?” Dharmaraj replied, “When you were a little boy.” Upon hearing this, sage Mandavya cursed Dharmaraj, “This punishment you have decreed is far in excess of the mistake committed by a child in ignorance. Be born, therefore, as a mortal in the world.”
धर्मो र्विदुररूपेण शापात् तस्य महात्मनः । माण्डव्यस्यार्थतत्त्वज्ञः कामक्रोधविवर्जितः ।
dharmo rvidurarūpeṇa śāpāt tasya mahātmanaḥ
māṇḍavyasyārthatattvajñaḥ kāmakrodhavivarjitaḥ
"It was Dharmaraj who was born as Vidur due to the curse of Sage Mandavya. Vidur was the knower of all virtues and ethics and also devoid of vices like attachment and anger."
Thus, as cursed by sage Mandavya, Dharmaraj took birth as Vidur- a son of the servant-maid of Ambalika, the wife of Vichitravirya. The world regards Vidur as a mahatma who was unparalleled in his knowledge of dharma, sastras, and statesmanship and was devoid of attachment and anger. While he was still in his teens, Bhishma appointed him as the chief counsellor of king Dhritarashtra of Hastinapur. Ved Vyasa, who also happens to be the father of Vidur, says that no one in the three worlds could equal Vidur in virtue and knowledge.
Source: Mahabharat