At the end of their rule, Pandavas decided to retire. It was time for them to bid good bye to civilization. Yudhisthira died during the final journey of Pandavas and it is mentioned in the Mahaprasthanika Parva.
Yudhisthira followed his wife, Draupadi, and brothers to the great snow-clad mountains in the Himalayas. Draupadi slipped and fell as they started climbing the Himalayas. Sahadeva fell next and died. Third to fall was Nakula. Arjuna fell next. And it was Bhima who fell next.
Yudhisthira who had decided to give up all the ties climbed the mountain leaving Bhima behind.
Yudhisthira and the dog that followed him reached the peak of the mountain.
Indra appeared before him and told him that he was blessed with immortality and happiness of heaven. He can abandon the dog and enter heaven.
But Yudhisthira was not ready to abandon the dog. He wanted the dog to be taken along with him to heaven.
Thus Yudhisthira abandoned heaven for the dog.
Indra was pleased with the Dharma of Yudhisthira. He praised the integrity and compassion of the Pandava for all living beings.
He then told Yudhisthira that the dog that followed him was Dharma. He followed you all the way as a loyal companion and you repaid that loyalty by not abandoning him. That earns you the right to enter the heaven in your mortal body.
Thus Yudhisthira entered the heaven in his own body and left earth.
Yudhisthira did not die on earth but entered the next stage of life in his own body.