North Korea's strategy is to deter foreign aggression against itself. As this article reveals, it has been an effective strategy, because the costs of war on the Korean peninsula are so huge despite the North's technological deficit.
What happens to the ~24 million DPRK citizens who are very low skilled? Whatever country takes them on is taking on a gigantic uncertainty and costs for literally millions of people. During famines, North Koreans have literally gone to the hillsides to get grasses to eat. Many are malnourished, roadways are poor outside of Pyongyang because they need travel permits to travel within country (so the roads are not used much). To make anything of the country would require huge infrastructure costs. Many of the roadways are also suspected to be rigged with explosives so if/when a land invasion occurs, US and South Korean troops are slowed down significantly.
China doesn't want to do it because the buffer between the "US sock puppet" called South Korea is nice to have. They have had trade going with North Korea for years, and recently have gotten annoyed by the rhetoric and BS spewing from their buffer zone.
With Seoul very near the border, South Korea stands to lose many billions of dollars in assets from artillery once the invasion starts.
One could argue that the US wouldn't need to maintain bases on the peninsula after the fall of the DPRK, but with the situation in the South China Sea, we'd be stupid not to and even if we agreed with China that we wouldn't, they don't have a lot of reason to trust we'd hold up our end of the bargain given our history.
The United States lost its mind when communism established a foothold in Cuba. Russia did likewise when Ukraine began aligning towards NATO.
China would prefer to have a stable regime in DPRK - but it would also prefer to not have US military bases on the other side of the Yalu river. The last time that happened, the two countries went to war.
Also, arguably, the DPRK regime is extremely 'stable'. The same royal family has ruled it for what, seven decades, now?
The current leadership does not strike me as 'stable' in any way. But then again, that goes for more world leaders.
All sibling comments talking about things like buffer states are missing the forest for the trees. You don't invade North Korea mostly because they have nuclear weapons.
No sane US administration (sighs) is going to risk over a million dead civilians in Seoul, Osaka or Tokyo and the resulting global recession.
For China, despite all the missiles NK lobs toward Japan, the reality is that Beijing is closer to Pyongyang than Osaka and likely has worse missile defense. A Japan with nuclear ambitions isn't high on China's priority list either.
You can hand wave their shaky missile tech away as a threat to Japan and China but that's a lot of lives to gamble on and there's a real possibility they've smuggled weapons abroad as well (more likely chemical than nuclear but still bad).
A lot also hinges on what sort of deal China could work out with SK and the US. Would US forces come all the way to China's borders? Would the US leave the peninsula entirely after the war? Maybe China could be bribed with a lease for a nice naval base on the Sea of Japan? I'd hope that there's been some discussion of all of this ahead of times given how the last Korean War went but who knows.
EDIT: changed 'we' to the U.S.
I cannot think of a regime changing American military excursion in the last 60 years that resulted in the scenario that America wanted, with the possible exception of Grenada.
That's a good reason to not invade.