I think there was a revolution at some point which brought in the communist party. I think at that point the revolution probably had a lot of support, thus, legitimacy. Just because people did not hold election does not make their government illegitimate unless power is taken by force.
The government does become illegitimate however if power is kept by brutal force. A lot of people died in the 1990s protests in China, the only country where the mass protests of people did not lead to a change of regime from communism to democracy.
But they are doing well now. They are kind of doing what Gorbachev did in the 80s, before the overthrow of the regime, that is slowly and gradually opening up. SO the people might overthrow their government soon as they did in Russia, or they might collectively decide some other form of governance. Democracy is not the only optimal option. We just have not thought of any other because we have not had to and just as the guys in china put up with communism, we do with democracy.
My point is, leave China to the sovereignty and will of its own people. Now, North Korea does need help.