The pro-government blog Russia Today, generally hostile to the West and the U.S., in one of its innumerable hagiographies of Vladimir Putin, pointed out that he had very generously allowed American forces to fly over Russian air-space to supply the troops in Afghanistan, only to be repaid by American and NATO ingratitude.
I don't know the precise details of what Russia has done for America, but one thing is certainly notable: though it has verbally attacked America over numerous issues, befriended anti-American regimes of every type, and repeatedly opposed it in the United Nations, it has, at least, not criticized it noticeably over Afghanistan. The Soviet-sponsored "peace" marches of the Vietnam War era have been notable by their absence around the world.
Whether this is due to Putin's good-will and generosity towards America is questionable. Russia can be seen as having a major interest in keeping America/NATO fighting in Afghanistan. Russia is the beneficiary in several ways. It is presumably not ungratifying for some Russian nationalists to see Americans/NATO and Afghans killing one another and exhausting their resources.
Further, the greater the number of American/NATO dead, the less outstandingly stark Russia's own humiliation in Afghanistan seems. This, however, is a relatively minor matter.
The only beneficiary of an Afghanistan weakened by prolonged war would be Russia.
Further, an Afghanistan controlled by the Taliban or some other extremist Muslim group would be much more disadvantageous to Russia than it would be to America: in the worst case of a Muslim extremist takeover of Afghanistan -- which now seems virtually inevitable -- it might carry out isolated terrorist attacks on America but would have neither the means nor the inclination to do much.
On the other hand, it borders Russia with a still-smoldering war against Muslims in Chechnya and a number of other Muslim areas -- there are enough Muslims within Russia's own borders to pose a major threat to its stability, especially given Afghanistan as a base. It is hard to imagine Russia going back into Afghanistan after the hiding it received there last time, but Russia is the main beneficiary of America/NATO preventing this takeover happening.
America has no clear policy objectives of its own in Afghanistan. Certainly, a Taliban or similar takeover of Afghanistan would threaten nuclear-armed Pakistan with a domino effect, but India has a vested interest in containing this. To complicate matters further, both the government of Pakistan and the official regime in Afghanistan are virtually as fanatical and anti-Western as the Taliban anyway – as the fact of Pakistan secretly sheltering Bin Laden for years bears witness. Pakistan already has a barbaric government that executed converts to Christianity or people who are judged to have transgressed arbitrary "blasphemy" laws.
In Afghanistan in 2011 a one-legged Afghan Red Cross worker and physiotherapist, Said Musa, 45, was sentenced to be hanged by the government for having converted to Christianity. No defense lawyer would represent him. Some were reported to have dropped the case after receiving death threats. He was held for about eight months in Kabul prison and reportedly tortured. He was eventually released after intense diplomatic pressure, but there have been many instances of the murder of Christians, judicial and otherwise. What are we doing with such savages as alleged allies?
America/NATO originally invaded Afghanistan to punish Muslim extremists for 9/11 and deprive them of a base. This was almost in the old tradition of punitive expeditions by which the British kept the peace on the frontier: banditry and lawlessness pushed too far by the border tribes (who were normally tolerated as a useful buffer zone) was countered by an expedition going in that burned a few granaries, blew up a few wells, and got out after showing the tribes that attacking the peace of the Raj did not pay. In his autobiography My Early Life, Winston Churchill vividly describes taking part in one of these punitive expeditions as a young officer. Punitive expeditions against the wild tribes of the border went on into at least the 1930s. Another great soldier/writer who described this latter period was John Masters in Bugles and a Tiger.
Things have morphed away from the original quasi-punitive expedition launched by President Bush -- which was justifiable and made some sort of sense -- to the present bizarre situation in which America/NATO is acting as Russia's policeman and fighting a war for Russia at the cost of thousands of lives and a further strain on their desperately stricken economies, quite apart from the damage to America's diplomatic position throughout the world and the fuel this otherwise pointless war provides for anti-Americanism. It is one of the very rare times in history that, far from being paid for fighting someone else's war like conventional mercenaries, an army is fighting someone else's war by proxy and paying for the privilege of doing so. It is easy to imagine the Kremlin is laughing up its sleeve as it generously gives American/NATO aircraft overfly rights into the meat-grinder. America/NATO should not wait around until some pointless deadline is reached with soldiers dying all the time. They should get out now, taking the moderate, Westernized and Christian Afghans with them.