The Cold War included a number of "proxy wars" between the US and the USSR, where instead of openly fighting each other (which could have led to full-scale nuclear war), the two superpowers armed and supported various intermediaries to do battle with one another in order to gain influence and control over different parts of the globe.
The Soviet-Afghanistan War was one such proxy war--actually more direct than most. In 1979 the USSR invaded Afghanistan with several thousand troops, immediately capturing Kabul and trying to set up a new Communist government there. This was actually the culmination of efforts for the last 20 years to establish a Communist government by subtler means. The result was a civil war.
In response to the invasion, the US (under President Jimmy Carter) boycotted the 1980 Moscow Olympics as a symbolic gesture. But the Soviets kept troops in Afghanistan and continued to try to maintain control of the country. When Ronald Reagan became President in 1981, he took a much more aggressive approach, arming a group of Islamist rebels known as the Mujihadeen to fight a guerilla war against the Soviets. He gave them high-tech US weapons such as M16s and Stinger missiles, which were used to great effect.
In hindsight we now know this was a mistake: The leader of that group was named Osama bin Laden. The United States helped create the Taliban and Al Qaeda by our short-sighted aggressive response to the Soviet proxy war.
Ultimately in 1989 the Soviets withdrew from Afghanistan because they realized they could never hold it. Afghanistan was freed from Soviet control, only to be taken over by the Taliban a few years later. Afghanistan has gone through a series of tyrannical governments and bloody wars ever since.