"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 necessary for a story. 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.
As this is an ending trope, assume examples will be spoilertastic.
Odysseus embodies this trope so much you could call it The Odyssey. He gets chewed out by Poseidon, loses all of his friends and crew in some very bloody deaths, is lost for 10 years when he finally comes back, and finds that his wife is being forced into picking a suitor, so he has to bring bloody death to them all with his son.
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 Eros had not forgiven her (he too had to earn it by coming to terms 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 fulfills 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.
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 anymore, 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.
To be clear, it is a bit more complicated than that. A person's good deeds do not directly merit their salvation, but refusing to do good deeds when given the chance is a mortal sin that can lead to damnation.
Well, it is played straight for Jesus. After all the hell (literal and symbolic) He went through to save us, the Book of Revelations seems to position 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.