I've read about how big of a deal the rise of the mujahadeen was in the spread of jihadist movements in the Middle East. Why did the USSR go in there in the first place?
The Soviet Union had a long border with Afghanistan, along what is now Turkmenistan, Uzbekistan and Tajikistan. It was a friendly country in an unfriendly area, between Iran (Pro Western, then violently Islamist) and Pakistan (Pro Western).
When the Mujaheddin threatened the socialist Afghan government, the USSR intervened, first sending military advisers, before replacing the president with a puppet and invading en-masse when it was clear the Afghan government and army was incapable of defeating the Mujaheddin.
The USSR always wanted buffer states between itself and Western allies or other hostile powers, letting the socialist government fall would put Russia's southern border at risk from violent Islamists or a Pakistani land-grab.
In the years preceding the invasion, the US had managed to flip Egypt out of the USSR's influence with the Camp David Accords, and were backing the Saudis in Yemen. The Cold War was a war of influence, and the Soviets found themselves essentially locked out of the Middle East, as no one was going to act while Saudi Arabia and Egypt was firmly in the US' camp.
In Afghanistan, a pair of coups resulted in a pro-Soviet government that had managed to anger most of the countryside. Afghanistan at the time bordered the USSR, and the last thing they wanted was a neighbor in a civil war that was influenced by their enemies (Iran and Pakistan). Unfortunately, as soon as they rolled in, their enemies made it out to be a war against Muslims.
Edit: Also, as a note, technically the government in Afghanistan requested the help, same as Vietnam.