Given that the 9/11 terror attacks were hatched in Afghanistan (not to mention the African embassy bombings and the attack on the U.S.S. Cole in Yemen) and the Taliban government was at the time giving refuge to bin Laden, it made sense to go in originally because if we hadn't then bin Laden and al-Qaeda would have continued unimpeded in their quest to kill Americans. However, after an offensive in January and February of 2002 drove bin Laden from his hideout in Tora Bora and drove the Taliban into a small sliver of Afghanistan, George Bush, Dick Cheney and Donald Rumsfeld made a fateful decision. The Taliban was almost gone, but instead of finishing the job and taking the final sliver of the country they held onto, the Bush administration put Afghanistan on the back burner and then used 9/11 as a rallying cry to invade Iraq, a country a thousand miles away that had nothing to do with the September 11 attacks. An invasion of Iraq had been on Bush's agenda since taking office after his father had made the decision not to finish off Saddam Hussein in the 1990-1991 Gulf War, and since then Saddam had continued to cause problems for the U.S. and other countries in the region.
By putting the situation in Afghanistan on the back burner, the Taliban were allowed to regroup and grow back, and by then were learning how to fight more effectively against the few Americans remaining; roadside bombs, suicide bombings and ambushes, especially in populated areas (the same tactics used later on by Iraqi insurgents after Bush claimed 'mission accomplished' a few weeks into the Iraq war.) By this time bin Laden had fled to Pakistan, so we were in effect fighting on one side of a civil war (and propping up a corrupt government then led by Hamid Karzai, which was known to be dealing, just as the Taliban were, in opium poppies that were smuggled out and into the world drug market.)
President Obama, like President Trump, ran on a platform that included getting American troops out of harms way. Only it didn't happen, and in fact eight months into the Obama administration (and on the eighth anniversary of September 11) I wrote a blog post critical of the Obama administration's Afghan policy. It seemed then that the Obama Afghan policy was really little different than the Bush policy. Obama's "Afghan surge" only got us in deeper and didn't ever seem to resolve anything. Yes, Americans and our allies might win battles and take territory, but just like any guerrilla war, once they left the territory it reverted back to the control of whoever had the support of the local populace (think about it-- HOW MANY times since the Afghan war began in 2001 have you heard about Americans backing allied Afghan government forces driving the Taliban out of strongholds in Helmand province? As soon as we leave, the place reverts back to Taliban control and we don't have the manpower to physically occupy all of it.) With bin Laden dead and al-Qaeda fragmented, clearly there is no threat from al-Qaeda in Afghanistan anymore. Of course now you keep hearing about 'ISIS in Afghanistan.' It's not like a bunch of ISIS fighters somehow traveled from Syria to Afghanistan. It's the same locals we have been fighting who are now calling themselves an affiliate of ISIS. And at some point we have to ask ourselves why we are still there. Does anybody even know what exactly a 'victory' in Afghanistan would be? No administration-- not the Bush administration, not the Obama administration and apparently not the Trump administration, has said what exactly the objective is in Afghanistan. If we are going to stay there then don't we owe it to our troops to state exactly what our purpose is and what we are trying to achieve? Vacuous statements like 'a stable Afghanistan' are useless as an objective. How do you measure 'stable' in a country that has been at war now for over forty years? And how do we plan to create it? If we can't answer these questions then we should GET OUT.