One of the points of society is to put as many steps between "Problem" and "Violence" as possible.
But sometimes the problem IS violence. A person has decided they prefer robbery to honest work because it's easier or more profitable, a person is murdering people, or even just a drunk person throwing a punch. In that case the proper response is to ensure that person can't hurt others, prioritizing the lives of the innocent over the aggressor. Sometimes if the threat they pose is high enough should they not be stopped the only option is to use lethal force.
D&D simply has a world where there are more problems of violence that can't be solved without violence than the real world, especially those involving lethal force. More people willing to murder for pleasure or profit, actual monsters who are eating people (in real life maneaters are put down as well), people with ideologies that demand they harm others, etc. Bandits in D&D aren't starving, they've just decided they'd rather kill and rob people than get a less profitable job and/or they like killing.
I'd argue current D&D might even be less violent than real life would be in the same situation since there are far more nonlethal options. Just imagine if police officers were equipped with wands capable of casting sleep instead of guns.
The problematic elements are just in how the violence is presented, like by having 'evil races,' treating enemies as sources of XP instead of people, etc.
And for the most part I've seen the problematic elements being addressed. As long as D&D books aren't putting in the problematic elements then it's on players and DMs to govern their own behavior.
I'm currently playing in a Rime of the Frostmaiden campaign and my party just got past a group of sapient giant toads by talking to them instead of attacking even though killing the toads would have been profitable and easier. We had to lie about being poisonous to prevent them from eating us but it felt wrong to attack first and I figure an arrangement can be made to feed them later.
At least for as long as I've been playing D&D, we weren't attacking bandits, goblins, orcs, or any other creature because we wanted to take their stuff. We were attacking them because those bandits, goblins, and orcs were attacking people. i.e. They were a threat to surrounding communities and our characters were tasked with taking care of the problem. We were supposed to be the good guys.
Yeah. Another example in Rime of the Frostmaiden was a group of yeti who were eating people. They had other options for prey so it wasn't a question of necessity and were sapient so it wasn't that they didn't know they were eating people.
My party went to their cave hoping to save their victims. The yetis attacked when we entered it and we slew them. I don't see how there are any moral or ethical problems there any more than there would be if the yeti were human serial-killing cannibals in the same situation.