The moon had been colonized by Earth for a few very straightforward reasons. The most prominent was that it held helium-3, a very potent fuel source that had made Earth dependent on it in a few short decades. The second most prominent one was the far lower gravity, which made producing and launching space missions easier, cheaper and far more reliable. Earth had pretty much stopped producing space ships since the space elevator started operating. The third reason was simply that they wanted to, it was close by and they owned it, goddammit.
And they had -- for centuries -- the belief that the Moon was Earth's. They were locked together, they had an effect on each other and dreams of colonizing it were by now so old nobody could really remember when the first time had been someone had dreamt of it.
But when you put people on any remote location, you can't expect them to abide by your rules forever. They'll form a separate identity, a new take on the culture they originally came from. But allegiances will inevitably change.
So once Earth started demanding too much, the Moon started sowing the seeds for their inevitable rebellion.
A secret armada was built, war ships and fighters, bombs and space lasers. The latter specifically because they sounded cool. They squirreled away helium-3, stockpiling it for later use, and built secret underground hideouts and bases.
For 5 years, everybody who was a true Mooner knew that hell would break loose at some point, and that they would win.
Earth seemed not to realize at all. They demanded higher helium-3 deliveries and the Moon delivered just a bit extra, squirreling away a little less until they could actually increase production. But the Moon soon had enough resources hidden away to become completely self-sufficient. Food production had become productive and reliable in their underground farms, and water reclamation from the ice found in the Moon's craters was now also running smoothly.
Earth demanded that the Moon build a new fleet of space ships, since their old fleet was aging and becoming difficult to keep operational. Many of them were too damaged by re-entering Earth's atmosphere to ever attempt it again. None of the ships they requested were war ships, since they had no idea they had any need for them.
The Moon obliged, providing them with ships with automatic shut-off chips that could be triggered from any Moon war ship.
When the Moon's unknown-to-Earth shadow government -- set up with implicit approval of the Moon's governor -- decided that it was time to stand on their own 90.000 feet, Earth had no idea what hit them.
The space elevator was, as far as Earth knew, suddenly de-orbited. The top elevator station crashed into the pacific ocean, cutting Earth off from space. Except for some of the aging fleet and the new, Moon-provided ships, of course.
Earth sent out messages to the Moon, asking what had happened. The Moon answered with a single message.
"Hey there. You don't own the Moon any more. We do. We don't need you for food or water any more, and we've got an armada of 250 war ships and even more fighters. You have ships available to you that we can destroy with the push of a button. You know as well as we do that all the real talent in ship building is up here. Our war ships are carrying bombs. Not to attack you, necessarily, but we thought it'd be a nice way to show you that we really don't accept your leadership any more."
On Earth, the UN and world leaders scrambled to figure out what to do.
In the mean time, the Moon took over the ISS-5 and Tiāngōng-32 within an hour after that original message was sent. Their crews were forced to send messages of capitulation to their respective mission controls.
After this, it didn't take much longer for Earth to respond.
"Message received and understood. We would like to offer a new relationship. One of mutual respect and sovereignty. The Moon is yours, Earth is ours, and together we build for the future. Let us know as soon as possible whether you accept."
The Moon agreed after only a short conversation in its now-official shadow government. Which no longer was a shadow government, really.
They knew full well that Earth would never be able to beat them in helium-3 production (of which they had none) or ship building (due to their atmosphere making it prohibitively expensive).
And that is how the Moon became independent, and Earth stayed dependent.
And when Mars was settled decades later, some of these lessons had to be relearned.
The hard way.