Having refused to enter heaven without the dog, and having been told that the dog was his father Dharma testing him, Yudhishthira is admitted, and the epic immediately does something crueller than anything in the war books.
He is shown Duryodhana, seated in splendour among the gods, honoured as a king who died fighting. He asks where his brothers are, and where Draupadi, and Karna. He is told they are elsewhere, and he asks to be taken there. The path goes down into a place of stench, darkness, mutilated bodies and thorns, and out of it he hears the voices of his brothers and his wife begging him to stay because his presence eases them.
He tells the gods to go back without him. He will remain in hell with his own rather than sit in heaven with the man who caused the war. At that the darkness lifts, and the whole scene is revealed as the final test. Indra explains that every king must see hell once, that his brothers were shown it briefly for their own faults, and that Duryodhana had earned the honour of a warrior's death.
Readers have never been comfortable with that explanation, and the discomfort is deliberate. The poem has spent eighteen books insisting that righteousness is difficult to see and costly to keep, and its last act is to put its most scrupulous character in front of a heaven that appears to have got the accounts backwards, and to have him choose his family over it. The choice, not the explanation, is the answer.