I agree with your observation that a lot of artists you see online struggle with mental health. However I wouldn't say that they create more often. Mental health issues especially depression comes with a lack of energy or drive, so if you got really severe symptoms chances are, you won't get a lot of things done. At least that is my experience.
I think the correlation of "bad mental health" and "creative people" comes from two places. First off, art is a wonderful way to express oneself. People, who are suffering, often have a need to do that, but may struggle in doing so in a direct way. So art can be a helpful tool to deal with ones emotions, which is why people with bad mental health or other issues might seek out this form of expressing themselves.
Second is that art itself can make you unhappy. It doesn't do that necessarily, but we all know the feeling of not having a picture look like we wanted it or seeing artists much better than us. On good days that's just a challenge to get better and finally reach the goals one has set. On others it can be devastating. And then artists go out to vent ^^ Art is a learning process and those can be frustrating if you put a lot of self worth in what you're doing. Artists also don't get the direct feedback a musician might get on stage, so it can be an unfulfilling hobby at times. Which is probably why you see a lot of artists with self esteem issues.
Of course that doesn't mean that there can't be creative benefits to the experience of mental health issues. A lot of artists use their experience to create really insightful works that expand the knowledge about the human experience. So they can turn that into a strength. But I would still argue that it is not easy to do that while you're really down in the dumps.