You don't normally expect heroes to kill willy-nilly. Sure, some of them have a licence to kill (sometimes literally, in the case of James Bond), but heroism sort of goes hand in hand with simple moral goodness. Anything diverging from that and you're in anti-hero (or even villain) territory, for the most part.
So it's always interesting when a hero is forced to make an excruciating decision for the Greater Good - that cause so worthy it turned a whole village into murderers in Hot Fuzz. And when it involves killing someone (or lots of people) so things are better in the long run, you're looking at a truly complex character moment that tends to inspire great performances and bags of emotion. So it's not all bad.
Sometimes, killing in the name of all that is good is the only way...
Thanos Snaps His Fingers - Avengers: Infinity War
Hero is a very loose term sometimes, but there's absolutely no question that Thanos isn't the hero of his own story. At least in the version that plays out in his own head, that is.
To the Mad Titan, his act of wiping out half of existence is one of mercy: he's looking after the long-term prospects of the universe (which will die otherwise) with a terrible short term solution that nobody but him would be brave enough to commit. Of course it's for the greater good (and he's not actually wrong on that front) - it's just that he doesn't REALLY go about it the right way.
10. Dr Manhattan Takes Out Rorschach - Watchmen
In Watchmen, Rorschach is pretty much the black sheep of the superhero ensemble: his methods are unconventional, his worldview cynical at best (and entirely nihilistic at worst) but he remained a self-appointed protector of men. Mostly in order to save them from themselves.
Right up until the finale, he was also the most grounded voice of reason - unseduced by the glamour of superheroism and not as disconnected as some of his fellow "Watchmen" - but once the reality of Adrian Veidt's plan for world peace through genocide, he flips on the rest of the heroes' moral compasses. He states his intention to uncover Veidt for what he is and threaten the fragile peace between the US and Russian built on their unified fear of Dr Manhatten and more genocide events.
And unfortunately for him, the only way to stop him - as he tells Dr Manhattan - is to kill him. He's an innocent, but he stands in the way of world peace, so Manhattan explodes him. All for the supposed Greater Good - though Rorschach's diaries will end up uncovering the truth anyway.