Another way to articulate that moment in history: "the USSR was disappointed with the main strongman in their puppet regime so they sent their best operators to murder him in the night".
I think you'd have to be quite naive to maintain that the USSR didn't have its local equivalent of a bourgeoisie. Or that a nominally Marxist economy like North Korea isn't really a dynastic monarchy hiding behind Marxist iconography.
It's a net loss under capitalist systems, too. Both systems can and do commit huge amounts of resources to pointless, destructive forever-wars. The political/military/security bureacracy of the USSR watched out for its own interests and sought ways to justify its own existence just as the military-industrial complex does in the USA.
The Soviet invasion enriched fewer bureacrats, but it also (compared to the NATO invasion) killed 10x more civilians and 3x more invaders in half the time, so in that sense I suppose we can say it was more efficient.
Only in capitalist systems is this a process of enrichment of the ruling class. The transfer of wealth in the US to the richest % on the basis of war has been immense. They're not pointless geopolitically either, since it serves to stifle and subjugate foreign governments into US alignment to support western predatory and exploitative economic policies (enforcing predatory loans and commanding oil trade). Hence aggressive imperialism combines several aspects of maintaining economic and military hegemony.
A government which was installed through a communist sponsored coup anyways
https://en.wikipedia.org/wiki/Soviet%E2%80%93Afghan_War#Red_...
>On 27 December 1979, 700 Soviet troops dressed in Afghan uniforms, including KGB and GRU special forces officers from the Alpha Group and Zenith Group, occupied major governmental, military and media buildings in Kabul, including their primary target, the Tajbeg Palace. The operation began at 19:00, when the KGB-led Soviet Zenith Group destroyed Kabul's communications hub, paralyzing Afghan military command. At 19:15, the assault on Tajbeg Palace began; as planned, General Secretary Hafizullah Amin was killed. Simultaneously, other objectives were occupied (e.g., the Ministry of Interior at 19:15). The operation was fully complete by the morning of 28 December 1979.
Funny fact, a lot of Taliban oldtimers are in fact former radical Marxists, and Maoists.