Yudhishtra was a human being. He was bound by the laws of Dharma. Since he was the son of Dharma devatha, his sense of understanding of, faith in, commitment to and practice of dharma were of the highest order, when compared to contemporary kshatriayas. He was head and shoulders above any of the kings of his period in the matters of dharma. Since he was a human being, he too faltered; got confused; yielded to temptations here and there. And he suffered for it.
On the the other hand, Krishna was a divine incarnation. Unlike Rama of Treta Yuga, who opted to consider him more as a human being —’Rama, the the son of Dasaratha’, Krishna of the Dwapara yuga had no qualms in accepting and demonstrating his Godliness at every opportune time.
By virtue of being God, he had transcended dharma and adharma. It is all his divine play and being divine, it is He who sets the rules or break the rules.
Hence comparisons have no meaning.