The correct answer is the first one: to force the Soviet Union's troops out of Afghanistan and destroy their supporters.
Al-Qaeda was founded in 1988 by the Saudi Osama bin Laden, in the context of the Soviet invasion of Afghanistan. This conflict took place between 1978 and 1992, and many Islamist and jihadist fighters from several Muslim countries went to Afghanistan to support the fight of their Afghans coreligionist against the Soviet army. Among them was Osama bin Laden, who founded a base -in Arabic <em>Al-Qaeda</em>- to fulfill the goal of expelling the Soviet troops out of Afghanistan.
After the war ended, Al-Qaeda was not dismantled, but under the direction of bin Laden it compromised in several conflicts across the Islamic world, it aligned to the Taliban in Afghanistan, participated in the conflict of the ex-Yugoslavia, and trained Somali jihadist militias among many other terrorist cells throughout the world. Al-Qaeda ended up fighting against the US, country that supported it during the Afghan war against the USSR. In 11 September 2001 it was responsible for the attack of the World Trade Center.