The problem is the difference in how the countries were run, who held power (as illustrated by land ownership below) and where their interests lied. Norway was gutted by the plague and its elite eradicated, however, the free-holding farmers were still strong.
Sweden had its interests to the east, to subjugate more of Finland and to control the trade in the Bay of Finland.
Denmark had interests in northern Germany and claims there.
The Hansa rightly feared a united Scandinavia as a threat to their trading interests, and were strong and skilled enough in diplomatics to always try to drive a vedge between the three Kingdoms. Sweden has no beef with the Hansa, especially not after Valdemar took Gotland and thus the only Swedish Hansaetic city, Visby. It is hard to make the Hansa and Sweden enemies OTL and, frankly, ATL too.
My take on how to get the Kalmar Union to survive is to remove Danish interests in northern Germany completely. Regardless of how they manage to pacify any parts they hold, conflict in northern Germany will come back to bite the Danes in their arse sooner or later, if nothing else then incited by the Hansa. Then the Danes will need money from Sweden, money that goes towards furthering Danish power and defending the personal holdings and prestige of the Danish King. The salt trade will be disrupted, and the Swedes will only see paying massive amounts of money and the salt price increasing for the benefit of the Danes. It will cause resentment, and any Swedish nobleman will either force the Danes to agree to decentralisation (which is bad for the long-time survival of the Union) or try to have himself crowned King. And then the cycle is at it again.
If you want the Union to survive, you need to change a few things.
You need a common enemy. In my opinion, it is easier to have the Danes keep Estonia and the Swedes and Danes having a common enemy in Novgorod, then Russia until the reformation, when Poland-Lithuania and the Holy Roman Empire and counter-reformation can be added to the list, than to get Sweden to be the enemy of the Hansa or any other north German state.
You need to avoid taxing and disrupting trade (especially the salt trade) for the benefit of the Danish King specifically (ie interests in northern Germany) for the Union to survive.
You also probably need to avoid the slide towards serfdom in Denmark, for the Swedish peasants were more afraid of going the way of continental and Danish peasants towards serfdom than they were of death itself.
Land ownership in the three Kingdoms (plus Finland):
Country-Crown-Freeholding peasants-Nobility-Church (roughly 1400-1500)
Sweden-6-52-21-21.
Denmark-10-15-38-37.
Norway-7-37-15-41.
Finland-4,5-90-3-2,5.
The Norwegians were especially hard hit by the plague (55-80% of the population dead) and with the "allodement" law (which meant that free-held land was owned by the user after 60 years) and lots of free-held land abandoned after the plague, the Norwegian nobility more or less ceased to exist - their tenants abandoned their land, and they were forced to become peasants themselves to survive. That is why the Norwegian nobility does not figure that much in the struggels over the Kalmar Union.