Communities were doing just fine without a CoC up until they became a trend. People got banned too but the moderators couldn't hide behind a CoC to justify questionable decisions.
> Communities were doing just fine without a CoC
I mean kinda, but also not. CoCs just codify what the moderators think.
Even Hacker news has a CoC: https://news.ycombinator.com/newsguidelines.html its just called a guide.
A community has to have a set of rules which most people agree on. One of the most common attacks in a moderated forum is "Oh but X did Y" and "thats not fair X can do it"
A CoC can be a simple way to "tap the sign" when someone is being a dick.
It also allows communities to set expectations at the start, not after someone has transgressed and pissed in the well.
In an ideal world, you'd just have a thing that says "don't be a dick" but that doesn't work for many and hilarious reasons. Engineers who who either have a god complex, parsing issues or empathy gaps (either learnt or inherent ) are notoriously difficult as a community to keep from getting into frothy arguments that colour everything and give off a bad smell.
CoCs are a tool, that can sometimes help.
Communities were not doing fine. CoC didn't come out of nowhere because someone was bored. Having a CoC doesn't absolve moderators any more than having laws absolves judges from having to make good rulings.