Russia used to make friends with other socialist countries. They smuggled weapons to Vietnam, sold their old ships to China, and now they're trying to help Kim stand his ground.
It's understandable that they don't want to allow USA to tip the balance of power. Kim is one of the few people crazy enough to attack USA and that would be an opportunity for Putin.
Who knows what he's planning, I'd expect an annexation of Ukraine or something like that.