The U.S. launched an invasion of Afghanistan in response to the 2001 terrorist attacks perpetrated in U.S. soil by that terrorist group.
The invasion did manage to weaken the Taliban for a few years in Afghanistan, but a big part of this victories came from the fact that many taliban factions and other terrorist groups recolated to neighboring Pakistan, where they enjoyed the protection of the government.