The greater good. Kirk & McCoy are Starfleet officers. They know what that means; the man said it himself: "Risk is our business." The President was given a simple choice: peace--but we try your men under our laws, our way; or you can try to get them back--& have war. Even if the Prime Directive hadn't stipulated that the duo were subject to Klingon law ("our territory, our rules") would you really weigh the lives of 2 figureheads against the lives of billions? No, he did the only thing he could have in the situation. He preserved the peace, & I not only think Kirk would have understood that & forgiven him later on, but if he'd been given the choice of "deliver yourself to the Klingons or it's war", he'd've not hesitated in saying, "Beam me over." That's not only the nature of command, that's the nature of leadership, & of understanding that sometimes you have to be sacrificed for the larger whole.