Once Arjuna asked Krishna who was a better king – Karna or Yudhisthira? Both might be generous, but who upholds Dharma (righteousness) the most?
Krishna replied that Karna was a better king and more righteous. Arjuna refused to believe him because Karna was not in his good books. Krishna reminded him that Karna siding with the enemy doesn't mean that he was any less righteous than Yudhisthira. Arjuna wasn't convinced. So Krishna decided to test them both. Both Arjuna and Krishna disguised themselves as Brahmins and headed out.
First they visited Yudhisthira and requested him to donate some dry sandalwood which they needed for a Yagna (ritual). Yudhisthira immediately sent his servants to the forest and asked them to collect dry sandalwood. He asked the guests to wait while the servants did their job. When the servants returned, they informed Yudhisthira that as it was raining heavily, dry sandalwood was unavailable. Yudhisthira explained the situation to the Brahmins and asked for an apology. He assured them that as soon as the rain stops, he would make sure that dry sandalwood would be delivered to them.
The two Brahmins then visited Karna and requested for some dry sandalwood. Karna immediately sent his servant out asking them to fulfil the guests' request. But they came back with the same results saying heavy rain made it impossible to find dry sandalwood. Karna asked the guests to wait and went inside. A few minutes latter, he came back with dry sandalwood. When the Brahmins asked him how he acquired them, Karna explained that he chopped down sandalwood from the pillars, furniture of his rooms and window frames.
The Brahmins thanked him and left the palace.
Krishna then explained to Arjuna what they just witnessed. Yudhisthira does something because it is written in the book of righteousness. He is limited to his learning. Karna on the other hand genuinely wants to help people and he likes doing it. Yudhisthira is not a bad in any way, Karna just has a better character than him and thus he's a better king.