It is almost certain that Yudhisthira was addicted to gambling. He gambled his kingdom, wealth, property, even Draupadi, etc. Although he was righteous, it seems that his weakness was gambling. So why was he able to climb Mount Sumeru when the other Pandavas and Draupadi fell due to their weaknesses?
Duplicate, but I'm answering anyways.
Killing is wrong.
Gambling is wrong.
But both have exceptions.
King killing men (or wealth) in battle when challenged is not wrong.
King pawning wealth (or men) in gambling when challenged is not wrong.
Moreover, it was supposed to be a game among family, with his own brothers, invited by his own father's elder brother.
Refusing it would be like refusing to eat dinner at your cousin's house. He had no premonition that they would resort to cheating or cruelty.
Indra already tells that it was already ordained that Yudhisthira would go to heaven in his very own human body when Yudhisthira asked Indra about how he can reach when his four brothers and his wife dropped.
"Shakra said, ‘Thou shalt behold thy brothers in Heaven. They have reached it before thee. Indeed, thou shalt see all of them there, with Krishna. Do not yield to grief, O chief of the Bharatas. Having cast off their human bodies they have gone there, O chief of Bharata’s race. As regards thee, it is ordained that thou shalt go thither in this very body of thine.’