It is a mess of our own making. When the Russians invaded Afghanistan, the CIA sponsored and funded fighters to come and fight a holy war. The Mujahideen formed the resistance to the invasion, and through a long war of attrition beat the Russsians by turning public opinion in Russia against the war, The daily loss of young soldiers' lives and the body bags arriving home persuaded the public and then the Kremlin, that the losses were not worth it.
How history repeats itself.
When the Russians left, there was a power struggle resulting in a civil war. Many of the foreign fighters the US had encouraged to come to Afghanistan, sided with the Taleban, and they were the victors. Many Mujahideen went home with plans to overthrow their own corrupt, western backed governments - Al Qaeda was born. When Al Qaeda needed a safe place to train, their friends the Taleban gave them a safe place.
After the devastating attack on US soil on 9/11 the US decided to overthrow the Taleban and destroy al qaeda and a full military invasion commenced. The fact that they have been unable to do either shows the folly of that action. Now we are at the same state the Russians were, with the public weary of the war and wanting out.
But not a humiliating withdrawal like the Russians, we need to pretend we have a victory by leaving a new Government behind. Unfortunately, for that to work, the new Government will have to include some Taleban members, because they do have some support.
So we are left wondering, was it all worth it, and the answer is probably - No.