How can the Communist government of Afghanistan secure its authority and rule over Afghanistan and be regarded as legitimate by a significant portion of the population?
If the Soviet Union hadn't collapsed, they could have won by exhausting the guerilla factions. Of course, this assumes that they themselves do not succumb to political exhaustion first.
That isn't a route to complete victory though - most likely there would still be guerilla groups being funded by Iran, Pakistan and the US as well as by opium trafficking right up until today, even if the Soviets survive that long.
Alternatively, and probably a much more sure path to victory, is to change things somehow in the turbulent period between Daoud's overthrow and the 1979 invasion.
For example, I can't help but feel that getting rid of Amin early (maybe he does during the Saur coup, or maybe earlier in '73 when the supposed assassination plot of the
Parchamite head of Daoud's Republican Guard supposedly planned to assassinate the entire
Khalq faction leadership - including Amin was a real thing and succeeds at least well enough to kill Amin) would lead to the Communist regime alienating less people. But all the sides who have gotten to write Afghanistan's history had some axe to grind with Amin it seems, so perhaps my view of him is unfairly skewed.
Or maybe Amin doesn't construct a North Korea-style cult of personality around Taraki, meaning Taraki is more in touch with reality in '77 and '78, allowing him to make wiser decisions.
Or, for a later PoD, perhaps the Soviets don't raise up the Parchamites in power in the aftermath of their invasion, leading to the alienation of the Khalq supporters in the army (which was a major driver of desertions after the invasion). If the Soviets allow the Khalq faction to maintain more of their power (and back the radical ideas of the Khalqites, rather than forcing the moderate views of the Parchamites onto the country), then they can much more credibly say "we are here assisting the government of Afghanistan at their request" and actually have a sliver of political support for their presence (albeit, that political support would be confined to the army and the cities).
None of these PoDs lead to everything being sunshine and rainbows for anyone, but it might make the mess in Afghanistan a little less and hence a little easier to actually get settled.
fasquardon