From Wikipedia
The War in Afghanistan, which began on October 7, 2001 as the U.S. military operation Operation Enduring Freedom, was launched by the United States with the United Kingdom in response to the September 11 attacks.
The stated aim of the invasion was to find Osama bin Laden and other high-ranking Al-Qaeda members and put them on trial, to destroy the whole organization of Al-Qaeda, and to remove the Taliban regime which supported and gave safe harbor to Al-Qaeda. The United States' Bush Doctrine stated that, as policy, it would not distinguish between terrorist organisations and nations or governments that harbor them.