The USSR never intended to get involved in such a conflict as
the Afghan War, but the major goal was to prop up the fledgling
Communist Government in that nation. The original goal was to
remove (assassinate) their previously backed leader, Hafizullah
Amin, who was straying from Communism. They succeeded at
eliminating Amin and installing Babrak Kamal.
Obviously the Afghans did not like having the Soviet military
invade their nation and take out their leader and soon the
resistance began against the Soviets.