Military action against Afghanistan was inevitable because the ruling Taliban allowed the country to become a haven and training ground for terrorists -- the same ones who carried out the terror attacks of 9-11.
Was a full blown invasion necessary? Could air strikes supporting the Northern Coalition have driven the Taliban out? We'll never know now.
The big mistake was the concept of marrying military action to "nation building" -- thinking the Afghans would be so happy to be "free" that they would instantly become modernized, westernized and our best friends.
When you are in someone else's country, you are an occupier, no matter how noble your motivations may be. Tribalism, religious differences and distrust of westerners made the "New Afghanistan" a no-go from the beginning.
The take away is that you can clean out a viper's nest, but don't expect them to love you for doing it. And don't base your foreign policy on that.