We all know that karma can be a bitch, but sometimes it's a total jerkass. It's not enough that the bad guy is a Karma Houdini. It's not enough that the good guy Cant Get Away With Nuthin. It's not even enough that he's a Butt Monkey or Chew Toy, put through the wringer for no reason. No, sometimes fate isn't satisfied until disaster befalls the good guy purely as a result of his doing the right thing.
If this happens because the hero helps people who are ungrateful, it can be a case of All of the Other Reindeer or The Farmer And The Viper. More often, helping out exposes the hero to some other danger, like the wrath of a villain whose plans were disrupted by said good deed, or the wrath of a populace that is opposed to the method of said helping out, such as in many Burn the Witch! stories that involve actual witches, or being Arrested for Heroism. Or being targeted by people who assume you have Chronic Hero Syndrome and so will be glad to help them for free.
Not every hero can handle this, and if it happens often enough or particularly badly enough, a hero may very well fall. If they stick it through even to the end, knowing what's coming to them, it shows who they are in the dark.
It should also be noted that this trope is more complicated than it looks. Sometimes good intentions bring unjust punishment, but sometimes good intentions result in very bad results because the good-intentioned person was also foolish, incompetent, ignorant, or just mistaken. In many cases whether a bad outcome was undeserved or not depends on the details.
As Robert Heinlein's character Lazarus Long observes in one story, "Good intentions are no substitute for knowing how the buzzsaw works." Which doesn't mean that life is not often cruelly unjust, it merely means that things are often not as simple as they look at first glance.
Named for a well-known saying attributed to Clare Boothe Luce. The Wide-Eyed Idealist is prone to this. Compare Being Good Sucks, where it's the act of being good (rather than the deeds themselves) that brings suffering, and contrast Laser-Guided Karma where every deed (good or otherwise) gets paid back in spades. If someone sees a hero going through this, it may lead to Sympathy For The Hero. Compare Androcles Lion, a Trope that can prove the exact opposite.
Incredible Hulk is another series that springs from this trope, with Bruce Banner paying an even more personal cost for saving Rick Jones.
Deadpool's bad luck is compounded by his own insanity and off kilter morality. He might do good, but even if he's acknowledged by the other heroes, instead of acceptance he'll receive a swift boot out of the city. Acceptance is all the guy really wants, which makes Wade's case even more tragic.
The Fantastic Four eventually invited him to their weekly heroes-only poker game. He didn't go, but it's the thought that counts.
The Sin City story "That Yellow Bastard" is this trope in a nutshell. All Detective John Hartigan wants to do is close his one unsolved case and stop a Serial Killer who likes to rape little girls and slash them to ribbons and put his ass away so that he can finally retire in peace. Said sick fuck happens to be the son of a powerful and ruthless U.S. Senator, one who will not stand for anyone messing with him, no matter how justified it is. As a result, Hartigan pays dearly for saving Nancy Callahan, the eleven-year-old girl slated to become the monster's next victim. Good lord, does he pay dearly. Said corrupt senator pays to have Hartigan's heart fixed, and then sets him up to take the fall for raping the girl (who didn't even get raped). Worse, he has to let his wife think he's the monster everyone says he is, because she'll be killed if he ever claims innocence. There's a special circle in Hell reserved specifically for the Roark family, but years later when Nancy is in trouble again Hartigan does get revenge by castrating Junior (again, and with his bare hands) before savagely beating him to death and then killing himself so that Nancy will be kept safe from the people behind Junior.
In Legion Of Super-Heroes Vol. 3 #19 (February 1986): "No Good Deed Goes Unpunished", a group of Legionaires are forced to deal with the menace that the Sun-Eater they destroyed was intended to stop.
In The Long Halloween Thomas Wayne saved the life of Carmine Falcone, since he's a doctor first and foremost dedicated to saving lives, and rebuffed Carmine's father's attempts to bribe him to keep the incident quiet. When this incident came to light years later it cast suspicion on Thomas' son Bruce. Harvey Dent — already resentful of Bruce Wayne's wealth — thought this incident was proof that the Falcones and Waynes had underhanded connections. Bruce even wonders if Gotham would have been better off if his father had put aside compassion and let Carmine die.
Just about every time a superhero Saves The Villain. The villain rarely ever appreciates the effort or does a Heel Face Turn. It just means the villain will live to make life hell for everyone else another day.
In the first issue of Ultimate X-Men, Bobby uses his ice powers to save a large group of people from a falling sentinel. He gets a bottle thrown at his head for doing so, since it just outed him as a mutant. Hell, the entire premise of X-Men is that they fight to save a world that hates and fears them, resulting in basically this.
Similarly, During Ultimatum, a lot of the X-Men die to stop Magneto, and the ones who survived did just as much. Mutants were just as effected by the attacks as everyone else, and most tried to stop it. Afterwords, mutants are being openly hunted by the goverment, the level of abuse they get has increased, and even thought mutants like Kitty Pryde risked their lives to help the public during the attacks, her peers are all bullying her and even report her to the goverment which causes them to come looking for her.
Ultimate Spider-Man ends with Spidey throwing all he has to stop the Ultimate Five, which ends with his death via a truck explosion.
Captain America briefly teamed up with Red Skull in an attempt to stop a resurrected Hitler from gaining the Cosmic Cube. This likewise rewarded Captain America with temporary exile from America by the US Government due to the latter thinking he turned his back on America.
Reed Richard's well-intentioned warning to Victor Von Doom concerning a few miscalculations in an experiment would be rewarded with decades of stories revolving around Doom's attempts to destroy Reed and everything/everyone he loves.
In Runaways, the main goal of the first arc is to free LA from the grip of the supervillain parents of the protagonists. All subsequent arcs deal with the power vacuum left behind, as countless other villains try to take over the area. And with most of the Marvel heroes stationed in New York, it pretty much entirely falls to the protagonists to keep the town safe. And later, Gert dies in one of those fights, in a situation that arose entirely from the fact that they killed off the Pride.
In the Civil War storyline, the teens are chased by Superhero Registration Forces because they were outed as superheroes... saving other officers from being killed by a crazy supervillain. The officer they save does apologize and urges them to run.
In the Third Movement of With Strings Attached, the four encounter a colony of shrunken humans being used as a science project by aliens. They unshrink the humans and take 40 of them back to C'hou to start a new life. But the humans resent being removed from their universe and, among other things, steal the four's personal stuff after the four are whisked away to look for the third piece of the Vasyn.
Summer Days And Evening Flames: Starfall puts his racism against griffins aside long enough to rescue Gilda from several criminals, freeing her from her bonds and defending her form would-be lethal blows. Although he did kill one (in defense of another), he was still arrested due to "vigilantism" by not being reinstated into the guard yet.
A Protectors Pride: For being the hero Ichigo always gets shafted when he saves the day. Example? He kills Aizen but when Ichigo needs to save his mom from Hell in a time-sensitive mission because of corrupt nobles in Soul Society, Yamamoto stalls him long enough that Ichigo's mother gets trapped there.
Myth and Legend
In some versions, Mordred of Arthurian legend. At the Battle of Camlann, Mordred draws his sword in order to kill a serpent at Arthur's heel during peace negotiations, but Bedwyr sees this as an act of betrayal and calls for war. This ends with Arthur and Mordred killing one another and Mordred being seen as a traitor forever.
As settings, both Old World Of Darkness and New World Of Darkness love this. Do a good deed? Well, it'll cost you a pound of flesh and probably not greatly impact things anyway. Do the easy bad deed instead? Get rewarded with power/riches/expediency, but dinged by the Karma Meter. Do option 1 enough times and you'll get killed or ground to a masochistic paste. Do option 2 enough times and you'll destroy yourself. Do half and half and live a quasi-happy/angsty life... for a time. Try to live in happy ignorance and apathy, and somebody else will ding your Karma Meterfor you when you aren't looking.
So common in Warhammer 40000 that it's rare to see anyone even try to do good deeds anymore. A quote from the forces of Chaos Codex: "Let no good deed go unpunished, and let no evil deed go unrewarded."
Dungeons & Dragons adventure A Hot Day in L'Trel in Dungeon magazine #44. After the PCs risk their lives to save a woman from a burning house, the woman sues them because she was injured during the rescue.
The Abyssal exalts in Exalted have this in spades. Picked out at death to serve Omnicidal Maniac undead gods and given corrupted divine powers, they can choose to go the Dark Is Not Evil route. Only the more positive, life affirming things they do, the likelier it is the said gods take over your body and someone you care about is randomly killed. This is why Abyssal Exaltation is the only type that both a) must be willingly accepted by the recipient and b) allows for the possibility of redeeming and changing state into a Solar Exalted. The designers already knew that it's a screw-over, and thus made it both require you to willingly sign on with the Neverborn (i.e., you've got it coming) and allow an escape mechanism.
Elphaba, the protagonist in the Broadway musical Wicked, finally has enough of her misfortunes during the song "No Good Deed," quoted above. By the time the musical number occurs, every major act of kindness or benevolence Elphaba's ever tried has blown up in her face. One of the more egregious examples came when her enchanting of her crippled sister Nessarose's jeweled shoes enabled Nessa to walk, just in time to have her heart broken by the man she loved, and in a jealous rage, snatch up the very same book that gave her the use of her legs and use it to cast a horrible curse on him, which Elphaba could only save him from by turning him into the Tin Man.
And to quote the Tin-Man: Holy Christ!
It's due to her I'm made of tin, her spell made this occur. And for once I'm glad I'm heartless, I'll be heartless killing her!
Plus, her attempt to save Fiyero's life also kinda backfired. She saves him from death, but her panicky desperate wording of the spell "Let his flesh not be torn, let his blood leave no stain. When they beat him, let him feel no pain, let his bones never break" turns him into the Scarecrow.
Which in itself is still a step up from what she thought had happened: With no way of knowing the outcome of her spell, she assumed it had failed completely and that he'd been beaten to death while crucified. No wonder she flipped.
At school she rescue's a poor Lion's life before he can be experimented on; he's later been convinced to blame her for his horrible fears and phobias.
As currently stands in Roommates each and every magical problem Sarah Williams ever had (including Labyrinth) can be traced back to her deeds in the Kid!Jareth arc where she... was nice to a child. For her misfortune: A Fair Folk Child From The Past, and fae are usually kinda clueless how to pay back such things.
Freefall has Florence the Bowman's Wolf, who in one early story arc gets involved in rescuing civilians from a hurricane and risks her life to save one Mr. Kornada. Kornada then steals her headset and forces robots to commandeer the ship, leaving her stranded in water so cold she has a life expectancy of 20 minutes — all so he can attend a completely pointless meeting. Arguably zigzagged in that this leads to Florence's Interspecies Romance with the human veterinarian who saves her life. The weight then sways back into "punishment" territory when Kornada nearly gets Florence frozen and shipped off-world, and is then revealed to be planning to electronically Mind Rape every robot on the planet, lobotomizing them, all so he can steal all their money. And completely oblivious to the fact that this could well destroy the fledgeling colony, which depends on the intelligence of the local robots to continue functioning.
Agent Washington from Red vs. Blue could be a poster child for this trope. He went against his orders to spare Agent South's life... and she shot him in the back as thanks (following orders from the same command as him, no less). After he returns to work, instead of receiving the support he needs to stop The Meta, he gets saddled with bureaucracy and a team full of idiots. And after he takes down that military organization and puts a stop to its numerous unsanctioned experiments based on fragmented AIs, he gets slapped with a number of criminal charges for his efforts (most notably, 7 counts of destruction of military property).
The ending of Operation Graveyard counts as this. See it HERE
In V4 of Survival of the Fittest, Luke Templeton talks Clio Gabriella out of committing suicide and generally helps her out. How does she repay him? By shooting him in the chest and head.
In his review for Babes in Toyland, The Nostalgia Critic was bothered throughout the entire thing by the Ghost Of Christmas Future, who was trying to get him to do a Christmas parody. But when he sees the ghost drinking and depressed, he puts on his daddy voice and tries to cheer him up by letting him pick what review he'll do next week. Big mistake, as the ghost instantly picks The Grinch, Jim Carrey version.
In the Whateley Universe, Bladedancer gets visions that she needs to leave Team Kimba and keep a low profile for something in the future. Phase, her roommate, helps. For Phase's good deed, he gets treated by the entire school like a jerkass who fired Bladedancer from the team and then booted her out of the room. Oh, and Phase gets a supervillain as a replacement roommate just to make things worse.
In Ultra Fast Pony, Twilight Sparkle goes to Ponyville on her own initiative, in order to prevent Night Moon Mare from destroying the world. After the day is saved, Princess Celestia arrives on the scene. She doesn't care at all about the barely-averted apocalypse—she only cares about the tea party that Twilight skipped in the process of saving the world. As punishment, Celestia banishes Twilight to Ponyville.