na vai vidur ṛṣayo nāpi devāḥ
na siddha-mukhyā asurā manuṣyāḥ
kuto nu vidyādhara-cāraṇādayaḥ
Maharaj Yudhishthir was the eldest son of Kunti Devi and Maharaj Pandu. Since Pandu was cursed by Kindama Rishi to die as soon as he tried to enjoy his wife, the couple were practically child less and barren.
Since Maharani Kunti was blessed bu Durvasa Rishi to invoke any demigod and as a result bear progeny with him, the couple decided to have their children through the way in order to expand their lineage. Srimati Kuntidevi first called Yamaraj and being pleased upon her, he gave her a child as good as him and his name was Maharaja Yudhishthir.
Since the child was born of Dharmaraj i.e. Yamataj, Maharaj Yudhishthir also got the title of Dharmaraj since he was always in favour of religious principles.
As instructed by Yamaraj to his Yamadutas (SB 6.3.19),