Society has laws, and any subset of society that forms into a community will draw tighter boundaries around what and how they define whats acceptable within their community.
Then add the lens that within any community there is always going to be power differentials where some people in the community have more power than others, by position, contribution, or just stupid historical reasons like "wealthy and has lots of free time". Declaring how power in the community works (i.e. who is in charge, who has decisionmaking, who has commit access) also needs to be written down.
So, anybody who's ever in a position to potentially be the target of poor behavior is much more likely to feel like the community has their back if something bad goes down, because its all written down about whats going to happen if somebody does behave out of bounds.
Since contributing or maintaining an open-source project is a pretty intense commitment to interpersonal interactions (if we all knew what code was right, we wouldn't need maintainers), it's good to know what beliefs a community has about desirable and undesirable means of interpersonal interaction before you commit to joining it.
Note that as a corollary, I think it's important that there exist communities have codes of conduct that aren't based on the Contributor Covenant etc. Linux's Code of Conflict is a pretty good example: https://www.kernel.org/doc/html/v4.12/process/code-of-confli... If that doesn't sound like it describes a community you'd enjoy, maybe it's good to know that well before you burn out on contributing to Linux (as many technically-prolific contributors have done). If it does, great, you'll enjoy the project and the mailing list.
Not necessarily. Being explicit has tradeoffs, both costs and benefits. One of the big costs is that it empowers people to behave antisocially on the "right" side of the explicit line drawn, and teaches people what they can get away with. Like, real life law grants broad discretion to human judges for exactly this reason - so that people playing bullshit games can get benchslapped for it.
They are not harmless, innocent things.
By comparison, imagine conferences and open source communities would be required to have a little footer saying "We are committed to making America great again" on every web site. Surely a harmless message nobody could possibly disagree with?
Everyone's unspoken idea of "decent" varies.
I also find it strange though. At least disheartening that teams feel the need to formalize these things. But at scale, it seems like a necessary evil.
That's problematic phrasing. "Decency" is subjective and sits too high up on the pyramid of abstractions. Decent people disagree on what being decent actually means. If they're actually going to communicate, the conversation has to be about specifics.
But if there is a CoC, you know they will have assigned some SJW as an overseer deciding what is OK and what is not. You know whose side they will be on. Which is not your side if you happen to be a heterosexual white male.
The tl;dr is, because an implicit code only works as long as no one actually uses it. As soon as an unspoken CoC is actually counted on to do something, people realize they didn't have the same expectations about what it meant, and so everyone on every side ends up angry and feeling they were treated unfairly.
I'd prefer to work with Linus Torvalds, and bear it out if he calls bullshit on me...