My take on the 'in-between' years:
From all indications, Kirk went willingly back into the Admiralty after the post-TMP five-year-mission. He would have been about 45 at that point, and (given his 'game for the young' line in TWOK) may have been burned out and simply decided "I'm getting too old for this shit."
is to be believed, he left Starfleet a few years later (again, fed up with the desk job) and retired to his family home in Iowa where he tried to settle down with a lady named Antonia. But for whatever reason (Spock/McCoy's prodding?), he couldn't go through with it and returned to Starfleet a year or so before TWOK, where he got the Academy job. (I think Spock was already there with the Enterprise
as a training ship, as he would have no taste for active command.) The Academy was probably Kirk's condition for coming back - "I'd rather be a schoolteacher than a bureaucrat." And Starfleet, as gottacook mentioned, would hardly be in a position to refuse him and just be glad to have him back in any capacity.
The way Spock and McCoy had to talk him into taking command, it's clear Kirk wasn't harboring any secret desire to get back in the chair - he simply didn't think he had it in him anymore. Maybe the 2'nd FYM wasn't as successful as the first (hence why no writers seem to want to cover it), or he suffered one Edith/Miramanee-style tragedy too many. Or, again, he was simply burned out.