The old Taliban government had no interest in the outside world so they did not care much that foreign Islamists used the Afghan mountains for training camps. Most of them came to Afghanistan to train for fighting in their own lands and topple their own governments, but then you have the tiny camp widely known as "Al-Qaida" ("The base") that believes the various Arab regimes, Saudi Arabia especially, can not be toppled without first getting America to abandon it's middle east interests. Not being able to match the American military might, Osama and his likeminded outlaw friends resorted to supporting opportunistic terrorism, including supporting Khalid Sheikh Mohammed who asked for funding to go through with his plan: the "planes operation", more commonly known as 9/11 or september 11 attacks.
Even before the September 11 attacks it was known that Osama Bin Ladin was hiding in Afghanistan and they were trying to build a case against him as the leader of a criminal organisation responsible for the 1998 bombings of US embassies and the 2000 bombing of USS Cole. Though he didn't have a direct role in any terrorism, Osama was justifiably seen as a danger to American interests and security. The US government demanded the Afghan Taliban government arrest and hand over Osama to America, the Taliban cheekily responded "Prove that he is guilty first", which wasn't well recieved in the US. In a very short time the Taliban government was destroyed and driven out of power in a spectacular invasion.
This is about as far as I can tell the story without going into politics. It is not about liberating people, Hitler used that excuse too. It is about protecting those that are useful to American interests, like the royal Saudi family and other Arab governments, from militant Islamists that seek to replace them. Afghanistan is rather insignificant to the world, it just attracts the kind of criminals that America sees fit to stomp with multimillion dollar bombs and gunships.
This might not be the story as you would deduce it only from western media. I am Muslim, and so I've been inclined to look at the Islamic scholarly perspective. This is a huge embarrasment to Muslim intellectuals, many who praised Osama as a hero and model Muslim for his efforts in the Soviet-Afghan war, but later having to admit they were wrong when he made himself an enemy of Saudi Arabia and eventually the rest of the world. The story of "Al-Qaida" and the Taliban can not be fully understood without the Islamic and Arab perspectives. The western perspective is slightly modified to fit the "war on terror" narrative. Far from a conspiracy, but you need to look at all angles to make out something resembling historical truth.