The military intervention in Afghanistan was a near complete success. Or it would have been, had the US pulled out as soon as it was satisfied that its initial objective had been achieved: the destruction of al-Qaeda in Afghanistan. That did not require occupying and taking over the country – a targeted punitive expedition (to use the jargon of past empires that got embroiled there) would have sufficed.
But occupying and taking over Afghanistan was what the US did, eventually calling on NATO and other allies for assistance in what became a state-building project. After twenty years, that add-on objective ended in total failure.
Read more here.