The bottom in is that we can't win and we can't leave, because if we leave then Afghanistan probably would be taken over by the Taliban again and become of major base for terrorism again. We went in there in the first place to clean out the terrorist camps--a valid effort, unlike our invasion of Iraq, which was started under false pretenses by the Bush administration (with major help from pro-Israel hawks). Afghanistan is a 50-year-project, at least.
The Taliban are nothing more than radicalized, uneducated and unemployed young men with nothing better to do than come down out of the mountains to harass foreign (U.S.) soldiers, then flee back to high ground when we pull out our guns. There is no "winning" there or anywhere in the mideast. The big problem in the region is socio-economic, not religion--too many people, too many uneducated people, too much corruption in the governments, too few jobs. Afghanistan is medieval and Pakistan isn't much better. When you are 100 years behind the rest of the world, radicalism is going to be a problem.
Did you see the article today about Trump cracking on his National Security Advisor, McMaster, because he has argued that the United States should essentially maintain the status quo in Afghanistan? Trump has apparently turned on his NSA chief for reasons not entirely clear---but one is that our brilliant president wants better options in Afghanistan. This only shows---again--what a moron Trump is. As noted above and is apparent to anybody with knowledge of the situation, there are no good or better options. You either keep a military presence there, as we have for years, to keep the country halfway stable and to help promote (a slow) modernization of the culture--or you leave and let the radicals gain control of the place again. It's really not that complex. Obama was smart enough and wise enough to get that and so kept a military presence in the country--and the government wants us to maintain a presence. Trump, because he knows nothing about the place and is stupid, apparently wants to stomp around his office and pretend that some magical solution can be found. He of course doesn't want to simply do what that Obama administration did. This is the instinct for stupidity that afflicts Republicans--they want to undue everything that Obama did, despite the fact that most of what Obama did was smart and forward-thinking. Hence we have a backward and idiotic government that wants to take a regressive approach to major issues.