It is certainly cool that President Obama can disappear from Camp David and suddenly reappear in Afghanistan and basically the public doesn't hear about it until he's there. Certainly it's best not to allow our foes to know of our commander-in-chief's movements in advance, and it's a good opportunity, at this holiday season, to boost morale and show our country's support to our forces.
I suspect there is another motive in the visit, one that I haven't yet seen reported (but as a blogger, I'm free to speculate upon it). It is a fact, well-reported, that one of the top leaders of the Afghan insurgency, Gulbuddin Hekmatyar, has made a recent peace proposal to the Karzai government. It would make a ton of sense for Obama to meet privately with Karzai to discuss the proposal and agree on a strategy to respond to it.
Hekmatyar is a guy who has been on the scene forever. He received aid from the US during the insurgency against the Soviet invasion in the '80's. He was one of the chief warlords battling over Kabul in the period after the Soviets' withdrawal and basically destroying the city...until the Taliban came and took over. He ended up going into exile when the Taliban were overthrown, and now his forces are fighting with them. He is a hardcore fundamentalist and an Afghan nationalist.
He should not be considered a Taliban leader, though: he's basically a warlord with his own independent power base, as well as considerable, continuing support from Pakistan. Clearly, he's looking to return, and his proposal, although not acceptable in its current form, would quite possibly form the basis for negotiating amnesty and a separate peace agreement, possibly even on terms that could attract other components of the insurgency. For example, he is not objecting to the continuation of the current government and control of security in the country. The timetables he proposed for withdrawal of Western forces don't align with US' plans, but are close enough to discuss. So, this is an opportunity which should be engaged, not passed up or flatly rejected.
This is complicated and delicate stuff, no doubt. Pakistan recently caught one of the top Taliban leaders--he was apparently involved in peace discussions with a special envoy backed with the UN for some time, so the arrest--while it seemed positive for the counterinsurgency--put an end to that channel for making peace. We have had to accept that Pakistan will have a critical role in what happens in Afghanistan. This is equivalent to the role we needed to acknowledge for Iran in Iraq's fate. You could also compare it to the interest the US might have had when Europeans put one of theirs, Maximilian, in charge of a weakened Mexico in the late 1800's. So, if Pakistan's guy wants to make peace, it can't be all bad.
Officially, it's Karzai's country and his play, but there's also every reason for him to review options with us, and there are probably a few tactics we can employ which would help him succeed in bringing this guy, and his forces, in from the cold.