Everyone in WALL•E. At the beginning of the movie, the Earth has fallen into decay and waste. After 700 years life finally sprouts again. Despite having lived lives doing almost nothing, the people of the Axiom are happy to set foot back on Earth and try to fix it. In the credits, we see society develop back to its former glory, and lush green fields and lakes are once again alive. Mankind has grown fit and thin again as they start doing things again. The real trick to it all? This is the SECOND happy ending, and this all happens in the credits.
The part in the credits was actually added after a test screening because about half the audience walked away making the rather realistic assumption that humanity died in about a week.
Everything WALL•E does to win EVE's heart pays off with EVE deciding she'd rather spend her life with WALL•E than follow the life her programming leads her to do. This leads to another potential happy ending that needs earning: WALL•E gets badly damaged and needs to be fixed with parts that can only be found on Earth, leading everyone who was affected by WALL•E in a beneficial manner to work together to bring him home. Naturally, WALL•E's Heroic Sacrifice does not improve his chances of survival, but it helps the above ending come to pass. Cue thirty seconds of EVE's hardcore repairmanship, coupled with True Love's Kiss, in an effort to save WALL•E's life. Guess how well that pays off.
While on the topic of Pixar movies, each Toy Story film had the characters go through so much to return home. Neither a cruel, sadistic kid, nor a villainous prospector, nor an evil pink bear could stop them. They did technically give up when they reached the metaphorical gates of hell, but they didn't really have any hope of escape short of someone operating the giant claw to save them - which is, of course, exactly what happened. And as bittersweet as the ending may have been, all the good guys earned a happy ending indeed.
For example, Bambi loses his mother, his home in the forest is burned down by Man, and he gets shot, but in the end has two kids and takes his father's place as the Great Prince. And the midquel only extends his seemingly endless hardships to greater heights.
Mulan could count as this. The titular character disguises herself as a man to save her father's life, and struggles to keep up at the training with the rest of the army, yet does it and earns the respect of the army. After being discovered as a woman, she goes to warn her old team that the Huns have survived the avalanche and are coming, and gets to fight the leader Shan-Yu. She defeats him using a paper fan. Along the way, she also earnes the respect and admiration of her captain without needing a matchmaker.
Treasure Planet. First old Jim loses his home, after trying to do something right, then the pirates mutiny against the ship he's on, then he's almost gets destroyed by a self-destructing planet. Only in the last five minutes when Amelia and Delbert are dancing do we see any real joy.
Lilo & Stitch does this with everyone but especially Nani, who spends the entire movie making increasingly desperate efforts to keep her sister, the last thing she has of her old life. By the time she gets a job, her home burns down and they take her away anyway. Then Lilo runs off and gets kidnapped by aliens, and Nani possibly loses her forever. Sure, it all turns out okay in the end, but you can't help but feel sorry for her.
In Wreck-It Ralph: Ralph finally gets accepted by everyone else, Vanellope becomes a part of her game's code again and is now able to race (and rule the kingdom of Sugar Rush), Calhoun—who lost her previous husband—gets a new husband (Fix-It Felix Jr.), and now, whenever Ralph gets thrown off the building, he looks through his game's screen to see Vanellope racing, winning, and being happy. Then the credits show the four main characters going into other games and having fun together. Everything's good.
Frozen puts Anna and Elsa through no small amount of tragedy, beginning with them being forced into isolation from each other and the world in the hopes of preventing Elsa from harming others with her powers, their parents dying, and Elsa's powers being exposed, resulting in her fleeing into the mountains to avoid harming others. By the climax, Anna is dying from slowly being frozen to death after Elsa accidentally strikes her with her magic, and Elsa wakes up, imprisoned in her own castle's dungeon, and learns that she brought endless winter on Arendelle. In the end, however, Anna's Heroic Sacrifice for Elsa saves both her sister and herself, and allows Elsa to understand that The Power of Love is the key to controlling her ice powers so that she can end the winter and stay close with her sister and her kingdom without harming either.
The Brave Little Toaster from the start sends its characters through an endless amount of crap and presents the harshness of reality in an upfront fashion, but they keep positive throughout the adventure and never lose sight of their goal. In the end, it definitely pays off.
Don Bluth made his career from this, and even his lesser films are united with his earlier work by this trope:
An American Tail heaps as much trauma on a (mouse) child as inhumanly possible, not giving poor Fievel a break until the last five minutes of the movie, when he finally gets to reunite with his family.
The Secret of NIMH: A frightened mouse mother struggles to keep her family safe from humans and conspiracies amongst the rats and literally is only able to save her family through her courage.
The Land Before Time: A group of dinosaur children undergo an odyssey to find a utopia (one of whom lost his mother at the beginning).
All Dogs Go to Heaven: A former criminal dog must change his ways and literally go through hell to redeem himself. By the end, he sacrifices himself to save a human child, and is finally allowed to go to Heaven because of it.
In The Pink Panther cartoon movie, Pink Christmas (available on YouTube, here), the Pink Panther spends most of the movie cold and hungry but gets a happy ending once he learns to share.
Po in Kung Fu Panda 2. He spends much of the film in a Heroic BSOD due to being tormented by visions and nightmares of his birth family, eventually finding out that he's the last of his kind. When Shifu said that inner peace is earned through pain and suffering he meant it. We find out at the end that he isn't actually the last of his kind though.
Film - Live Action
Batman Begins: Bruce loses his parents and all sense of purpose in his life other than vengeance against his parents' murder, Joe Chill, then loses that purpose when Joe Chill is murdered by a hitwoman for the Gotham mob. Then Bruce runs away from Gotham to try to understand the darker aspects of life and to find a way to overcome them. Bruce is then presumed dead and Gotham has to suffer for years through an economic depression as well as a corrupt legal system where almost every cop is a Corrupt Cop, the mafia rules the city and crimes like murder are extremely common. As Gotham loses hope, Bruce is trained by Henri Ducard, a Knight Templar who helps Bruce regain hope and find purpose in fighting crime...but Bruce has to betray and leave Ducard to save when he finds out Ducard wants to destroy places filled with crime (like Gotham). Bruce returns to Gotham as Batman, and fights to give the city hope against both normal criminals and Dr. Jonathan Crane...who gives Ducard a fear toxin that Ducard plans to use to destroy the city. Batman then must overcome both his fears and the returning Ducard (AKA Ra's al Ghul) and the League of Shadows to save his city. After much struggle, with Wayne Manor being burnt down and then some of Gotham's slums being driven insane, Batman saves the day and gives Gotham hope for the first time in years. To emphasize this, the Bat-signal triumphantly shines in the night for the first time during the final scene.
The Dark Knight: Yes, there are criminals who will do almost anything for money, and unapologetic evil that cannot be bargained with, and the Knight in Shining Armor can fall, hard. But in the end, Batman is able to apprehend The Joker without becoming the monster Joker wants him to be. And the citizens of Gotham pass Joker's "social experiment" (if only barely) by not turning on each other like he predicted.
At the end of the final movie in the trilogy, The Dark Knight Rises, Bruce Wayne seems to have finally put his past behind him. He fakes his death — but leaves subtle (or not-so-subtle for some) clues of his survival to his Secret Keepers (giving them their own happy ending rather than leaving them in mourning) — and retires with Selina Kyle who, after helping Bruce save Gotham, has her own criminal past erased to allow her a fresh start as well.
Serenity ends with the people of Miranda avenged, River somewhere closer to sanity, and Mal having put some of his demons to rest... but only at the cost of two of his crew members and a lot of innocents. It says something about Joss Whedon's Signature Style when Serenity has one of the more upbeat endings of his works.
Saving Private Ryan ends its War Is Hell theme with this quite explicitly, with Captain Miller telling the eponymous private to earn it when he returns to the 'States. The Epilogue shows him as an old man at Captain Miller's grave in France with his wife, children and grandchildren, and has him breaking down and asking his wife if he was a good man. Manly Tears were shed, especially by battle hardened old men in the audience.
The world of Quantum of Solace may be a Crapsack World, with the official stances of the CIA and MI6 to let Quantum, the Nebulous Evil Organisation, do what they want in the name of oil, but at the end of the film, James Bond has torn open a huge hole in Quantum, earned his solace over Vesper's betrayal and death, helped Camille get revenge and remove a would-be dictator, and given the Bolivian people their resources back. Leiter also gets promoted to his corrupt chief's position.
Slumdog Millionaire, applies this literally — almost every horrific thing that happens to the characters contributes to Jamal's win.
Sam: It's like in the great stories, Mr. Frodo. The ones that really mattered. Full of darkness and danger, they were. And sometimes you didn't want to know the end. Because how could the end be happy? How could the world go back to the way it was when so much bad had happened? But in the end, it's only a passing thing, this shadow. Even darkness must pass. A new day will come. And when the sun shines it will shine out the clearer. Those were the stories that stayed with you. That meant something, even if you were too small to understand why. But I think, Mr. Frodo, I do understand. I know now. Folk in those stories had lots of chances of turning back, only they didn't. They kept going. Because they were holding on to something.
Frodo: What are we holding onto, Sam?
Sam: That there's some good in this world, Mr. Frodo... and it's worth fighting for.
David Mamet's Redbelt. Through a veritable Deus Angst Machina noble jujitsu instructor Mike Terry loses his business, his reputation, and his best friend, and is forced to fight in a PPV match. Once there he not only discovers the matches are fixed, but that it was his own wife who caused his downfall. After a brief Heroic BSOD he becomes determined to make it to the ring and reveal the truth about the fixes. On the way there, he defeats the arrogant jujitsu guy, is awarded the championship belt, has a moment with the woman whose life he probably saved, and when he reaches the ring is embraced by his life-long mentor, who gives him the highest honor in jujitsu - the eponymous red belt.
Sky Blue follows Shua as he desperately tries to bring down Ecoban in order to mitigate the environmental damage it has caused to his home. Dr. Noah notes that most of its inhabitants will survive and be able to forge a better world, but it will take a lot of work.
The 1924 version of The Thief of Bagdad. It's written in the stars...
The Shawshank Redemption.The possibility that Andy could escape was given hints earlier on that were deliberately so subtle that one was likely not to notice them until re-watching the movie, partly because of the overwhelmingly dire nature of the situation he was in. One particular example is the rock hammer; Red thought it'd take centuries to tunnel out of prison with it, but it was vaguely hinted at, by the scene where it took a decent sized chunk out of the wall, that taking it one day at a time still left the possibility of an eventual escape.
Schindler's List: The movie adaptation of his life implies he never recovers from the events of World War II, either emotionally or financially, but seeing Liam Neeson portraying Oskar Schindler standing in front of all the people he saved at the cost of virtually everything he owned, hundreds of people there, and then having a Heroic Blue Screen of Death because it was only virtually everything he owned, when if he'd gotten rid of literally everything he may have saved perhaps a dozen more... and then the epilogue reveals that the Final Solution in Poland was so severe that fewer than four thousand Jews remained there at the time of the film's release... and then, finally, The Reveal that the descendants of the Jews Schindler saved number over six thousand.
That's assuming one interprets the ending of the movie as actually happening in reality. An other possibility is that several of the characters never actually emerge from Limbo and the happy-ending is just part of the main character's dream. Given the alternatives, being trapped in a happy dream forever (relative to one's perception of time) may qualify as a happy ending for him though anyway.
If you take Christopher Nolan's own interpretation as canon, it doesn't matter if Cobb's back in reality or not, what matters is that he's finally gotten over his wife's death and he's finally gotten to see his children again. The fact that he's finally happy since he first fled the US is what matters, and the fact that he had to work to achieve that happiness certainly qualifies for this trope.
That way of seeing it even holds true when you go with the most extreme interpretation of the ending: that in fact his wife was right and we never saw the real world in the entire movie.
In Love Actually, most of the couples fought and made sacrifices for the name of love. Sam learned how to play the drums and then escaped the security guards at the airport to reach his crush. Both Jamie and Aurelia learned the other's language so they could properly speak to each other when they meet again. David and Natalie went through a Second Act Breakup, only to realize that it was a misunderstanding and they make up. Colin sold his apartment to go to America, where he meets four stunning American girls who were very interested in his British accent. The couples that didn't work was because they didn't take the chance to make it work or were unable to move on (like Sarah whose duties to her mentally illy brother took priority over her crush Karl).
In a rare example of this trope spanning several connected films instead of just applying to the course of the plot throughout one film, Young Frankenstein. All the five earlier Frankenstein films in the original series (alluded to being in continuity with Young Frakenstein with the line, "We're still having nightmares..from five times before!") had unhappy endings. Young Frankenstein was the first to end quite happily—because it was the first Frankenstein film in which the doctor does take responsibility for his creature and even shows fatherly caring for it.
The characters in Mystery Team had to go through their first REAL case in order to grow up and become respected.
In Arashi No Yoru Ni, things just seem to get worse and worse for the main couple, but it all works out in the end eventually.
Jenna has to go through a lot of abuse and self assessment in Waitress till she gets her independence.
Transformers: Dark of the Moon has Sentinel Prime turn out to be a traitor to the Autobots, Chicago devastated by Decepticon forces, Sam and Carly having relationship troubles, and the Autobots untrusted by the world. But by the end of it all, Sentinel Prime and all of the Decepticons are killed and defeated, Sam and Carly get together again by the end, and the Autobots have proved they're not the reason the Decepticons are staying on Earth.
In The Last Samurai after the destruction of the samurai army and the death of Katsumoto, although the Narrator says that no one is sure what happened to Algren, the final scene shows that he made it back to the village and Taka to find "some small measure of peace."
The Artist has George Valentin lose everything as a silent film actor and filmmaker in a artform that seems to have passed him by and comes within a hairsbreadth of suicide, only to be saved at the last moment and shown that he has talent that would make him a star in the sound era.
The 2013 CBC movie Jack, about Canadianpolitician Jack Layton, shows him fighting the uphill battle throughout his political career against powerful rivals, and dismissiveness from those who figured he never had a chance; eventually, though, he made it to opposition leader status before he died. Granted, it's not an entirely happy ending, but it's uplifting compared to most of the movie.
The hero of Im Juli has to suffer a lot in order to get from Hamburg to Istanbul and meets his love.
In Nurse Betty, after all the bad stuff which happens to the main character (Like for example, being traumatized as a result of witnessing her husband's brutal slaying, to the point of not being able to tell the difference between fiction and reality.) things end well for her: She not only recovers her sanity and also manages to don´t be killed by the two hitmen that were trying to eliminate her, but also gets a job in her favorite show and the movie concludes with her taking a vacation in Rome, while she plans to pursue nursing as a career.
GoodDick The central couple overcome abuse, drug addiction, mental illness, a pornography addiction on their way to happy together.
Elysium: Though The Hero Dies, medical aid is rendered to Earth, Frey's daughter is cured of her leukemia, and the villains of the story are dead.
This Is the End mixes this trope with a Dance Party Ending. Thanks to their selfless actions and enduring Hell on Earth, Seth, Jay and Craig get to go to Heaven and enjoy all of the luxurious things that it has. One of which is partying with Backstreet Boys, a life long dream of Jay's.
Boyz n the Hood has Tre who has kept clear of gang lifestyle despite living in the ghetto thanks to his strict father. When his best friend Ricky is gunned down, he almost gets pulled into the violence of his 'hood by seeking revenge alongside Ricky's brother Doughboy. Thankfully, he has a change of heart before revenge can be carried out and returns to his father. He goes on to attend college out of a state with his girlfriend where as Doughboy unfortunately is killed in retaliation by rival gang members.
Noah has the closest one we'll see in an Aronofsky movie. After enduring the violence of man, the flood wiping out humanity, Noah almost killing his newborn children and their son Ham leaving them, Noah and his family prosper on their new land with the animals, with The Creator bringing life to the planet once more.
For both parties in Neighbors. The fraternity moves closer to the campus i.e away from Mac and Kelly, allowing them to raise Stella in peace, and Teddy grows up and gets a post-college career as a male model while taking night courses to boost his GPA. He and Mac also make up.
Apparently so in Youth in Revolt. Nick wins Sheeni's love, and she agrees to wait for him while he's in juvie. Whatever he may have done, no one can say he didn't work to earn her love.... But, if you keep watch during the credits, a cartoon epilogue scene plays where Nick escapes from juvenile hall and finds Sheeni driving down the road, so then he gets in the car with her and they fly around the world.
Not to mention that everyone from Nick's deadbeat parents to Francois seems to have given them their blessing, in spite of everything that's occurred...
In spite of the destruction that occurred over the course of Godzilla (2014), the victory over the Mutos and Godzilla's return to the ocean are portrayed in a triumphant light.
For the former, after so many years since their last show, The Muppets were practically forgotten by the general public, and when they attempt a comeback to save their theater, new obstacles keep on appearing, Kermit comes close to losing it, and they initially don't even succeed in reaching their goal either, but they won back the hearts of the general public and have become as beloved as ever, and even getting their theater back thanks to a change of heart from Tex Richman, and not because of Gonzo's bowling ball knocking him out.
For Walter. His whole life growing up was a constant struggle, and one of the few things that helped him get through was his brother Gary and his love for the Muppets. He not only managed to bring back his heroes together to save the show, but was acknowledged as one of them so unconditionally that it was nothing less of a dream come true. The scene just before the final music number was him being lifted by the Muppets in front of their cheering fans.