Why did Soviets invaded a sovereign country?
It was a complex situation so I will post from a few Wikipedia pages.
From the page about Daoud Khan :
Khan met Leonid Brezhnev on a state visit to Moscow from April 12 to 15, 1977. He had asked for a private meeting with the Soviet leader to discuss with him the increased pattern of Soviet actions in Afghanistan. In particular, he discussed the intensified Soviet attempt to unite the two factions of the Afghan communist parties, Parcham and Khalq. Brezhnev described Afghanistan's non-alignment as important to the USSR and essential to the promotion of peace in Asia, but warned him about the presence of experts from NATO countries stationed in the northern parts of Afghanistan. Daoud bluntly replied that Afghanistan would remain free, and that the Soviet Union would never be allowed to dictate how the country should be governed.
After returning to Afghanistan, he made plans that his government would diminish its relationships with the Soviet Union, and instead forge closer contacts with the West as well as the oil-rich Saudi Arabia and Iran. Afghanistan signed a co-operative military treaty with Egypt and by 1977, the Afghan military and police force were being trained by Egyptian Armed forces. This angered the Soviet Union because Egypt took the same route in 1974 and distanced itself from the Soviet Union
From the page about Babrak Karmal :
Karmal remained in exile until December 1979, when the Soviet Union intervened in Afghanistan (with the consent of Amin's government) to stabilize the country.
So there was no invasion like how NATO invaded Libya in 2011 or how USA and a few allies invaded Iraq in 2003.
Communists declared state atheism in Afghanistan till 1987, Afghans were natural to revolt against it, they believe in Islam.
Even Albania, USSR and PRC were / are outwardly atheist states but I am sure people did practice their old beliefs.
The problem in Afghanistan for the state was not Islam but continuation of non-Islamic tribal practices like honor killing and burqa which continued despite the socialist state.
The revolt which you mention, probably did have some Afghans seeing the socialist state as a counter to their traditional life but the main opposition to the socialist state was from NATO and its supported militants who came from foreign countries.
Imperialistic game of Soviet and Americans destroyed the dreams of Afghans, both owe reparations to them.
Well, as ever, the Western governments owe reparations to lot of countries in the world.
In fact the Taliban were the only ones who gave the Afghans a stable govt in a century.
You must write what is your understanding of "stable".
They were "stable" because the Americans allowed them to rule, until just after the 9/11 attack.
And the Taliban shutting down barber shops, music shops, pushing women into burqa, pushing women out of schools, setting up a morality police squad etc... how can this be taken as normal ?