Earlier quoted context omitted.
Same situation as Wikipedia: Absolute power corrupts absolutely - but so does a small, petty amount.
I think it's significant though that both wikipedia and stack overflow, despite being ruled by petty assholes weilding the smallest amount of power in seemingly the stupidest way possible, have become two of the most valuable references in existence. Do toxic communities produce better content?
Well I'm not sure about that. Wikipedia is the better of the two, but that's a low bar. Articles are poorly written, inconsistent, and targeted at wildly variable levels of existing knowledge. I rarely use it for anything other quick lookups of trivial facts (and even then only for unimportant purposes). It's much-visited, but that's an indicator only of ubiquitous availability. I remember long ago reading some study or other comparing its quality favourably to old-fashioned encyclopedias, but it was just a fairly risible surface fact-checking operation. Of course Wikipedia is huge so there may be vast areas of excellent quality unrelated to my interests.
SO is worse, but a little more useful because of its narrower scope.
So, no, IMO toxicity of community and quality of output aren't related (in either direction).