"And though the story may have dark turns, it is so the ending might become all the brighter by comparison."
— The Clockmaker, "The Clockmaker's Daughter", Flight
The basic idea of this trope is that a cast of characters in a story go through a lot more hardship, anguish and grief than is really necessary. In the end, however, you see them get their happily-ever-after. While humans may act bad and the world may seem like it's a crapsack, that doesn't mean that the worst villain is beyond redemption, or that things can't be improved with hard work or even The Power of Love.
Not to be confused with the Golden Ending in video games, where players actually have to earn their happy ending. It is possible for both tropes to be in play at the same time, however.
As this is an ending trope, assume examples will be spoilertastic.
Odysseus embodies this trope so much you could rename it The Odyssey. After surviving the blood Trojan War, Poseidon develops a grudge on him, he suffers numerous misfortunes, near-death experiences, and a trip to the Underworld, eventually loses all of his friends and crew and is left to drift on the sea for months, is made a sex-slave for a few years, has been gone for two decades by the time he finally comes home, and finds that his wife is being forced to pick a suitor, so he and his son have to slaughter them all. And his dog died the minute he caught sight of him.
Technically she fails - she falls into an eternal sleep. It's Cupid who, coming out of his depression, gives her her happy ending, by pleading to Zeus.
Though, they both needed to earn their happy endings. So, even if Psyche had finally gained Aphrodite’s forgiveness and approval it would not change a thing if Cupid had not forgiven her (he too had to earn it by coming to terms with the fact that his wife is fallible, and standing up to his mother).
Hercules seemed to have had this misfortune. Before he is even born Hera conspires to make his life as hellish as possible by denying him the kingship Zeus intended for him. Throughout life he is attacked by snakes as a baby, forced to undergo twelve years of harsh labors after killing his family in a Hera-induced rage, additional torments thrown on by Hera during those years, everywhere he goes he has to fight monsters or gods, is often cheated by kings after he fulfils his obligations to them leading him to seek retribution later, save Olympus from a race of giants, and is betrayed by his second wife who inadvertently poisons him with hydra blood leaving him in agonizing pain and has to be burned alive. His crime that started all of this? Being born the son of Zeus. All that waited for him in the underworld? Wandering around wheat fields in the dark for all eternity. The least Zeus could do was elevate him to godhood.
Aeneas as well. His city, Troy, is burned by the Odysseus and the Greeks, he sails around on the Mediterranean Sea for six years, meeting every threat that Odysseus did, lands in Carthage where he marries the princess Dido (who commits suicide when he leaves) and upon arriving in Latium, enters into wars that kill off most of his friends.
Some religions have this as their premise - life is hard. Being Good Sucks. But it is worth it, in the end - the evil are punished, the faithful are saved, and we go on to our reward, forever and ever.
From the last book in The Bible, describing the end of time, Revelation 21:3-4,
And I heard a loud voice from the throne saying, "Behold, the dwelling place of God is with man. He will dwell with them, and they will be his people, and God himself will be with them as their God. He will wipe away every tear from their eyes, and death shall be no more, neither shall there be mourning, nor crying, nor pain any more, for the former things have passed away."
Subverted in that people can't "earn" or "work" their way to heaven by filling out a checklist. In Paul's letter to the Romans (specifically, Romans 11:6), he says this in regards to how to "work" your way to heaven:
''And if by grace, then it cannot be based on works; if it were, grace would no longer be grace."
In other words: no matter how hard you work, you can't earn your way to Heaven. This sounds pretty bad at first, until you realize that Paul's meaning in this is that because Jesus died for our sins, all we have to do is accept him as our savior to make it to Heaven, which is a lot easier than trying to earn brownie points with God.
Played straight for Jesus. After all He went through to save us, the Book of Revelations identifies Him as the future ruler of the Ressurected faithful. This is somewhat subverted in that, being God, his dominion over us should have been His birthright rather than something earned, and many people will end up in Hell anyway.
The last part of which really depends on the teachings of one's denomination, Lutherans believing that all have been saved by Christ's sacrifice regardless of any sins whereas the Catholics teach that one must accept salvation and some have to go through Purgatory before their eternal reward.