StackOverflow was successful explicitly because of the people/question it excluded . The "toxicity" was the point. It was trying very very hard not to become Yahoo Questions. If you want to hear more about this you should watch Joel Spolsky's talk "The Cultural Anthropology of Stack Exchange": https://www.youtube.com/watch?v=LpGA2fmAHvM The point of StackOverflow was explicitly not to help the question-askers, but to…
I mostly chalk it up to UI affordances. The most obvious one: the site constantly presents an "Ask Question" button; it gives you a form to type in a question; people come to the site because they have a question, and it goes live to a general audience[1] as soon as it's posted. No amount of emphasis on search is ever going to override that.
Less obvious but much more important is that the community can't actually put information about community norms in front of new users, except by scolding them for mistakes. No matter how polite you are about giving people links to the tour[2] or to policies[3],
Then of course, they wanted the site to actually grow at the start, so we got that terribly conceived reputation system best described as Goodhart's law incarnate[4]. And it was far too successful at that early growth, such that if anyone actually understood the idea properly at the start, they were overwhelmed by new users (including the experts answering questions) and had no chance to instill a site culture. It took until 2012 or so until a significant chunk of the experts were getting frustrated with... all the same things they were historically frustrated with on actual forums; then we got the "What Stack Overflow is Not" incident[5]. A lot of the frustration was misdirected except for a general annoyance at certain stereotypes of typical users. It took until at least 2014, from my assessment of the old meta posts, for a real consensus to start emerging about what makes a good question, and even then there was a lot of confusion[6].
Newer sites like Codidact[7] have a chance to learn from this mess, establishing ideas about what good questions look like, and about site scope, from the start[8].
1. Notwithstanding more recent efforts, like the Staging Ground and now a new "question type" feature (https://meta.stackoverflow.com/questions/435293) which seems to have been recently rolled back in preparation for something bigger (https://meta.stackoverflow.com/questions/437856), and the various attempts to force AI into the process, etc.
2. https://stackoverflow.com/tour
3. Especially things like 'Under what circumstances may I add "urgent" or other similar phrases to my question, in order to obtain faster answers?' (https://meta.stackoverflow.com/questions/326569) and 'Why is "Can someone help me?" not a useful question?' (https://meta.stackoverflow.com/questions/284236). See also https://news.ycombinator.com/item?id=46485817 .
4. https://meta.stackexchange.com/questions/387356/the-stack-ex... ; the anchor is for my own answer but please scroll around and read other points of view.
5. See https://meta.stackexchange.com/questions/137795. Back then I was actively using the site but not active on meta; I pretty well gave up in 2015 for largely unrelated (personal) reasons, then came back in mid 2019, coincidentally shortly before the Monica situation[9].
6. In particular, see 'How much research effort is expected of Stack Overflow users?' (https://meta.stackoverflow.com/questions/261592), originally authored 2013, and especially compare the original answers to newer ones. Notably there were also quite a few deleted answers on this one, for those of you with the reputation to view them. Also see 'How do I ask and answer homework questions?' (https://meta.stackoverflow.com/questions/334822) which largely misses the point: it's not so much about the ethics of someone cheating on homework, but about the question fitting the site model.
7. https://codidact.com , with subdomains for various topics. Notably, "programming" as a topic is not privileged; unlike how the Stack Exchange network started with Stack Overflow which still dominates everything else put together, software.codidact.com is just another section of the site. Full disclosure: I am a moderator for that section.
8. See for example https://software.codidact.com/posts/285035/289176#answer-289... ; https://software.codidact.com/posts/291064 ; https://software.codidact.com/posts/284979 ; https://software.codidact.com/posts/292960 ; https://software.codidact.com/posts/294610 ; https://meta.codidact.com/posts/289910 ; https://meta.codidact.com/posts/290028 ; https://meta.codidact.com/posts/291121/291156#answer-291156 ; https://meta.codidact.com/posts/289687 ; https://meta.codidact.com/posts/289951 ; https://meta.codidact.com/posts/284169. Yes, this is a carefully hand-picked list. I have a fairly clear mental image of one more but was somehow unable to search for it.
9. See https://meta.stackexchange.com/questions/333965 and many others. It's a deep rabbit hole. It's also the triggering incident leading to the creation of Codidact[7].