Lord Yama is the god of death, and it is his duty to remove our life during the time of our death. Lord Yama is a Vedic god, and whoever performs the fire sacrifices, and chants his mantra, he receives the oblations from the fire sacrifices, and used to bless them. Lord Yama would always follow the path of righteousness and he would give great respect to the devotees of Lord Shiva and Lord Vishnu.
According to the legend, once Rishi Mandavya was captured by the soldiers of a king, since they have mistaken the great sage as a thief, and as per the orders of the king, they tried to hang him in the prison. But due to his spiritual and meditative powers, the great sage began to float in the sky. On seeing his supreme powers, the king realized his mistake and asked to pardon him. The sage had forgiven the king, and went to the Yama Loka to find the reason for the punishment given to him.
Lord Yama Raj had welcomed the great rishi, and after hearing the details from him, he answered to him, stating that, during his childhood, he playfully tortured small insects, and due to that, he had been given the punishment, he said like that.
On hearing the words from Lord Yama, sage Mandavya had become angry and told to him, that whoever commits sins during their childhood would not be counted as a sin, and they are not considered as culprits under the eyes of the Dharma Deva. Then he cursed Lord Yama to be born in the earth as a human, and to suffer from the problems in the earth. Due to that Lord Yama took the avatar of the great and the noble Vidura, and lived a pious life, and after the end of his life, he merged with Lord Yama.
From the above incident, we can know how the great Lord Yama is also accepting his mistake and taking birth in the earth in the form of a human being. Lord Yama always follows the path of dharma, and usually he would not commit any mistakes. Instead of getting afraid of him, we can worship him regularly, chant his mantra, and can get relieved from the death fear.
“OM SRI YAMA DHARMA MAHARAJAVE NAMAHA”