Kirk saved the Earth from destruction. The "admiralty" and everyone else on Earth would have died if it wasn't for Kirk. Everyone knew this, and no one was pissed off at him. The charges were a formality. You could even tell that the president even knew it was all bullshit. Kirk got what he wanted, command of a starship, and everyone knew that was what he wanted, and deserved.
The idea that Kirk was given a malfunctioning ship as the result of some sort of revenge plot by Starfleet is utterly ridiculous.