This has all started back in 60's when Soviet and Chicom became mutual adversaries. N. Korea decided play one country against the other, securing steady aid from both countries, which were anxious to keep NK under its orbit, or at least keep them from falling into the other guy's orbit.
After Soviet collapsed, this game was no longer viable. Both of them no longer felt the need to woo NK. So NK regime had to find a new meal ticket. They found it and it is nuke.