Ten years of western occupation of Afghanistan led the UN this week to plead that half the country's drought-ridden provinces face winter starvation. The World Food Programme calls for £92m to be urgently dispatched. This is incredible. Afghanistan is the world's greatest recipient of aid, some $20bn in the past decade, plus a hundred times more in military spending. So much cash pours through its doors that $3m a day is said to leave Kabul airport corruptly to buy property in Dubai.

Everything about Afghanistan beggars belief. This week its leader, Hamid Karzai, brazenly signed a military agreement with India, knowing it would enrage his neighbour, Pakistan, and knowing it would increase the assault on his capital by the Haqqani network, reported clients of Islamabad's ISI intelligence agency. Meanwhile, in Washington, the Pentagon is exulting over its new strategy of drone killing, claiming this aerial "counter-terrorism" can replace the "hearts and minds" counter-insurgency. Down in Helmand, visiting British journalists gather to recite the defence ministry's tired catechism: "We are making real progress on the ground."

The opening decade of the 21st century has been marked by two epic failures by the western powers that so recently claimed victory in the cold war; failures of both intellect and leadership. One is the inability to use the limitless resources of modern government to rescue the west's economy from prolonged recession. The other is the use of an attack on America by a crazed Islamist criminal as an excuse for a retaliatory war embracing a wide swath of the Muslim world. The decade-long punishment of Afghanistan for harbouring Osama bin Laden has been an act of biblical retribution. The demand that it also abandons the habits of history and adopt democracy, capitalism and gender equality was imperial arrogance.

What happened in Afghanistan in the autumn of 2001 has spawned an industry of hindsight, with over a hundred titles of wisdom after the event. We learn of the post-9/11 arguments within the Taliban, many of them old CIA allies. We learn of the possible role of Abdul Haq in Kabul, of Pakistan's intelligence double-dealing, and of the Kandahar jirga of October 2001 which came close to evicting Osama bin Laden.

Yet every counsel of caution in dealing with Afghanistan was disregarded in America's rush for vengeance – even the warning of Donald Rumsfeld that America "had no dog in the Afghan fight" and should avoid nation-building after a punitive raid. A great surge of imperial eagerness seemed to overwhelm Washington, London and Nato, as if the whole of western liberalism were craving a role in the world.

The occupation of Afghanistan has been a catalogue of unrelieved folly. America is spending staggering sums on the war, which it is clearly not winning. Congressional studies show virtually no US aid reaches the local economy, most remaining with contractors in the US or going on security or being stolen. Local democracy has failed, as warlords feud with drug lords and tribal vendettas resurface. The "training of the Afghan police and army" has become a dope-befuddled joke.

Britain's part in this has been dire. The thesis that Whitehall and its NGOs could somehow end Afghan corruption was absurd. Clare Short's mission in 2002 to "eradicate the poppy crop" and Kim Howells' spending of £270m "defeating the drugs trade" were beyond satire. I still have before me John Reid's briefing as gung-ho defence secretary in 2006, that Britain's job was "to build a prosperous, democratic, stable and secure Afghanistan", with British troops "not waging war but helping to rebuild". I recall General Sir David Richards at the time assuring me it would all be over soon in Helmand thanks to his "inkspots" strategy. The conclusion drawn in Frank Ledwidge's book, Losing Small Wars, is that the performance of Britain's 16 Air Assault Brigade in Helmand was "nothing short of disastrous … leaving a legacy of destroyed towns, refugees and civilian casualties". Whitehall's compensation payments to Afghan civilians killed and injured by its troops are doubling each year.

Three hundred and eighty-two British soldiers have died in this war. Can any minister look their families in the eye and claim the loss was worth it? Worth what? Except in garrisoned towns, security in Afghanistan is as bad as ever. British soldiers have been told that they are being withdrawn over the next two years. Since they cannot pretend to have achieved their mission, it makes no sense to leave them in harm's way a moment longer.

The policy now is to "talk to the Taliban", as if it were the German high command on Luneburg Heath. All that is happening is that Karzai's emissaries and Taliban chiefs are seduced into "talks", and then murdered either by their own side or by America's trigger-happy drones. Five of Karzai's negotiators have already been killed, including his brother. The drones are removing one Taliban or al-Qaida leader after another. While it is hard to feel sorry for them, the wrecking of any hierarchy of control replaces a path to peace with renewed vendetta. American policy has turned the tiny cell of Bin Laden's al-Qaida into a global terrorist brand.

What is strange, as Barbara Tuchman wrote, is not the folly of policy as such but its immunity to correction even when known to be folly. Any visitor to Kabul soon learns two things. First that it is senseless to confuse Pashtun nationalism with Taliban insurgency, and that with al-Qaida terrorism. Second, if Nato wants to eradicate a security threat in this part of the world, some accommodation must be made with the mujahideen or, as the Russians found, they will simply win. Accommodation, that is, with their Pakistan sponsors. The only key that unlocks this door is the departure of Nato troops.

As during Vietnam, some wars pass the stage where politicians and generals dare step back and look. Pride, a craving for glory, an aversion to defeat, above all, the institutionalising of the war in its surrounding territory, come to drive strategy. Kabul is occupied by tens of thousands of soldiers, diplomats, NGO officials and contractors. Afghanistan has become a stew of the military/industrial complex, with aid mixed in.

American estimates from Brown University are that some $3.7 trillion will have been spent avenging the 9/11 deaths. Britain's contribution to this stupefying sum is £18.8bn. Whether this spending has prevented another terror attack, whether that would be value for money, or whether the whole venture has been little more than a cruel exercise in vanity, machismo and greed can never be answered, though Bin Laden himself was dealt with quite cheaply. All we know for sure is that revenge has not been sweet, just very expensive.

The irony of this great folly is that its chief beneficiaries are likely to be those who lost the cold war, Russia and China. As the west's leaders struggle to rescue embattled armies and embattled economies from morasses of their own creation, they have left their old foes laughing with glee. Democracy has snatched defeat from the arms of victory – without a shred of a reason.