Helluva big question, Afghanistan was the hub for many terrorists cells.
They could go and learn how to set up their organisations and how to make bombs etc. with Al Oaeda acting like a Q.M stores.
Iraq was always for me ab it of waste of time, whereas Afghanistan is winnable to my mind.
Afghanistan was an awful place under the Taliban, it was a threat to national security and it is the national interest to build a stable and just society there.
The problem with Iraq was Bush, he had no exit strategy, he had no idea how to instal a government that was acceptable to the people.
Afghanistan is different, the ethnic and tribal makeup of Afghanistan is far removed from that of Iraq, centralising a government will be hard and will probably require some sort of federal government with elected official from each area representing the tribes in Kabul but being largely autonomous within themselves. Dynastic China may prove a useful model for that idea.
In the meantime I feel we should pay the farmers over the odds for their corn, and then sell it at below cost price to the local corn traders and then gradually reducng the subsidy to reinvigorate the commercial infrastructure and stave off heroin production, either way it's gonna take a good 30 years (at least) to have a trulty stable country there