In Cloudy with a Chance of Meatballs, Flint is ostracized in the town because his inventions always fail spectacularly, which is a shame, since most of the things he invented were made with the intent of helping people out. Even when he invents something that does end up working, saves the town from a depression, and gets him the love and respect he always wanted, it still manages to Go Horribly Wrong in the end, threatening to destroy the whole world.
In The Dark Knight Sal Maroni explains to Batman that nobody will tell him where The Joker is because Batman has "rules," while the Joker does not. In a choice between the two, it's healthier to make Batman mad to avoid pissing off the Joker than it would be the other way around.
In The Dark Knight Rises, Bane became Talia's protector and helped her escape. This selfless action on his part resulted in several prisoners exacting revenge on him by beating him within an inch of his life, forcing him to don an anesthetic mask. And later he was banished from the League of Shadows because of his relationship with Talia.
The plot of Dragonheart is kicked off when Draco agrees to give half his heart to save the dying prince...who then grows up terrorizing the kingdom and can't be killed unless Draco himself dies. To twist the knife on poor Draco, he ends up being the Last of His Kind directly because of the deed, since Bowen blames his heart for "corrupting" the already evil prince and vows to wipe out all dragons in retaliation.
In Escape to Witch Mountain, Tia saves a man's life. That man, Lucas Deranian, turns out to be an employee of Aristotle Bolt, a billionaire searching for supernatural powers to exploit. Bolt sends Deranian to pose as Tony and Tia's uncle, bringing them to his isolated mansion.
In A Fistful of Dollars the Man With No Name manipulates the Mob War in San Miguel with ease; the only time he messes up and gets himself in real trouble is when he stops focusing on making money for a second and decides to free a woman the Rojo brothers were holding captive. This act tips off the Rojos that he's not on their side, leading them to ambush, capture, and torture him.
Ending of the French comedy Le folie des grandeurs - Blaze saved the king's life, revealed all conspirators plotting against the king and sunk down Don Salluste scheme to ruin the queen's reputation and sacrificed his love to her so man who he impersonated could become her lover. Sadly, during all of it he makes the king believe he's in love with old Dona Juana and has to choose between marrying her or being sold into slavery. He ended as a slave of the same Arabic Sheik who bought the conspirators and Salluste. Good news � they don't hold a grudge against him. Bad news � Dona Juana comes after him.
Another Lindsay Lohan movie, Georgia Rule, gets outright literal in here: Mormon Harlan gets to Georgia's house to fetch her grand-daughter Rachel (who performed oral sex on him on a canoe) to convince her to get to his actual girlfriend together with him to release him for his sins. When Georgia yells at him that it wasn't a big deal, but just a blowjob, and Georgia comes into the scene in a severely shocked manner, Rachel just responses that "no good deed goes unpunished".
In the Halloween (2007) remake, Ismael, the only security guard in the institution who ever showed Michael Myers compassion and stopped the others from bullying him, is given an over-the-top and painful death. The poor guard's final words are a tearful, "I was good to you, Mikey!"
In the sequel, the daughter of one of the rednecks who beat down Michael for trespassing pleads with them to leave him alone, and at least apologizes when they leave him for dead. Dead just the same.
In The Incredibles, Mr. Incredible stops a suicidal man from jumping off a building but accidentally injured the guy in the process. The dude "repays" the favor by suing him. This, and a buck of other lawsuits from people injured in the process of being saved, leads to a registration act that forces all superheroes into hiding, and the actual person responsible for their injuries, Bomb Voyage, ends up getting away with it scot-free, since it was his bomb that resulted in the railroad tracks they were on being destroyed and forcing Mr. Incredible, who was trying to save Buddy Pine from being blown to smithereens by that bomb, to stop the train from falling over the gap caused by the explosion.
In In Time, Will's mother dies as a direct consequence of giving Will enough money for lunch.
Actually the Designated Villains of the film, as they constantly help out the Designated Heroes by saving them from the dinosaurs, only for them to usually cause an incident that has the dinosaurs attacking them.
Mean Girls: when Cady goes to apologize to all the people she's hurt, she includes her math teacher "Mrs. Norbury, who's living proof that no good deed goes unpunished".
To be specific, Mrs. Norbury is concerned by Cady's declining grades, which she knows is a result of Cady pretending to be less intelligent than she really is, just to get the attention of a boy. While trying to motivate Cady, Mrs. Norbury tells her she's a "pusher" and intends to push Cady to fulfill her potential. All this does is cause Cady to twist her words later, telling the Plastics that Mrs. Norbury is probably a "drug pusher". They get her to write that in their notebook, which is later distributed to the school, causing Mrs. Norbury to be arrested on suspicion of drug dealing.
Happens in the end of the Mexican film Un Mundo Maravilloso, but not to the protagonist: The main character (a homeless hobo), having crossed the Despair Event Horizon because he believed his wife was dead (she wasn't, as he happily finds out soon after), wanders into a middle class neighborhood during a storm, a middle class family upon seeing him from the inside of their house immediately out of kindness offers him shelter and gives him clothes, blankets and food. How does he repay them? Near the end of the film after deciding that "Better a day as a rich than a lifetime of poverty!", he with the help of his family and buddies, invades and takes over that very same middle class house, killing its owners.
No Country for Old Men. Llewelyn Moss would have gotten away with stealing the drug cash if he hadn't gone back to give water to a dying man.
In The Silver Lining Playbook Tiffany's husband, after coming home from buying her lingerie to spice up their relationship, helps a motorist who's broken down, he's struck and killed by a passing vehicle.
In Snake Eyes, Nicolas Cage plays a sleazy corrupt cop who suddenly finds his conscience when he uncovers and subsequently tries to prevent a plot to assassinate a political whistleblower. He succeeds, and in the epilogue he is initially hailed as a hero, but winds up going to jail after the extra publicity shines a light on his shady past.
Wu Xia: Xu Baijiu has this as his motivation; He once caught a kid stealing from his parents, but let him go him without telling anyone. He got poisoned for his trouble.
While one can argue over how much of a good deed it was, the people who created the mutant cure in X-Men: The Last Stand only wanted to improve the lives of mutants. They underwent a violent invasion of Magneto's mutant army because of it, and at least one was killed off pretty horribly.
In Face/Off: Castor Troy, posing as his nemesis, defends his nemesis's daughter from a date-rapist and gives her a switchblade to use against further attackers. In the end, he tries to take her hostage and she uses the knife on him.
The Elite Squad: Matias trying to get Romerito spectacles. The student he told spilled the beans to the drug dealers and when Neto volunteered to help him pass them to the boy he gets fatally shot.
This is a recurring theme of The 400 Blows. When Antoine's grades falter, he commits himself fully to completing a writing assignment...and gets accused of plagiarism. Likewise, near the end of the film, he steals a typewriter and gets arrested for it. The kicker? He's not arrested during the actual theft; he's arrested after he feels guilty and tries to return it.
Byzantium: Poor Noel. He takes in an apparently desperate mother and child and ends up dead for his trouble.