It ultimately comes down to a sense of responsibility.
Some creators believe that all the responsibility to critically read their work, its messages and the things it puts forward as "fact" or "how the world works" should be on the reader and that they should be allowed to write anything they want, even if it depicts marginalised people in potentially damaging ways, even if it normalises slurs, even if it glorifies violence.
Some creators believe that the responsibility is all on them. That since fiction has such a profound effect on people's perception of the world, that they should be careful what ideas they're putting in people's heads.
Personally, having read the research on how strongly fiction impacts empathy, I've come to stand on the "I have a responsibility" team. In fact, the first time this came up, I was just eight years old....
So, there was this one boy who was ALWAYS bullying me. He took every opportunity. He once put lemonade in a waterpistol so he could shoot me in the eyes with lemonade (YES. IT REALLY HURT), he would call me names, he would steal my stuff... and one day, I'd had enough so...
I drew a picture of him looking like a complete fool and I left it on my desk.
So the next thing I know, I'm being quietly taken aside by my favourite teacher, who was sympathetic, because that boy was a little s*** but his parents were wealthy PTA members and very influential in our little local area, so the school always wanted to be on their good side. Anyway, the boy had come running to the teachers in floods of tears because I'd made him look like a fool and all the kids were laughing at him. What that teacher explained to me then were words I've always lived by; my ability to draw is more powerful than any weak insults he could throw at me, or even any punches, because it can legitimately influence how people see him and how he sees himself. I'd never really thought of art as powerful like that before, and it had a big effect on me.
I think it's true though. When I went to spend study in Japan, I was shocked by how many British people's ideas about Japan were shaped almost entirely by:
1. The book "Memoirs of a Geisha"
2. That one Simpsons episode where they go to Japan (you know, the "MISTER SPARKLE!" one?)
So people had all these misinformed ideas about Japan that they'd got from fiction that doesn't even necessarily claim to be factual and simply never questioned. Bits of misinformation like "Japanese cartoons regularly cause seizures", "In Japan they have American-themed restaurants", "Geisha are basically high-end sex workers", "Japanese people are obsessed with honour, and if dishonoured will stab themselves in the stomach with a katana" (that's not even how seppuku works...
).
The things you put in your work may confirm or challenge people's world view, or put ideas into their heads that they'd never thought about. If your story only has one gay character and he's a bitchy fashion designer who is really creepy to your cis-het male protagonist... you're reinforcing 1.Gay people are not main characters because we're not "normal", we're a fringe group. 2. Gay men are confined to being flamboyant artists, they can never just be a normal guy. 3. Gay men are threatening and off-putting and if you don't like being near them that's justified because they might do scary things like perv on you!
As a note, it's worth remembering I didn't really come to terms with the fact that I'm gay because media in the 90s and before so consistently depicted lesbians as being big, butch, gruffly-spoken, always angry OR sexy bisexual dreamgirl who doesn't really exist IRL who wants threesomes all the time. I couldn't see myself as gay because I hadn't seen a character who was a swotty dork girl who was gay, and then Willow from Buffy happened... and I was like ".....wait."
So yeah, I am VERY careful about what I put in my work. Not least because I'm a queer female creator and will inevitably be judged with double standards (see: Steven Universe and Owl House discourse...). With great power comes great responsibility, and being able to write and draw is a pretty great power.