The popular preference for a story with "a happy ending" is not, or at least was not, a mere sweet-stuff optimism; it is the remains of the old idea of the triumph of the dragon-slayer, the ultimate apotheosis of the man beloved of heaven.
Some stories just end happily, with the villain defeated (or the basic problem resolved) and the heroes triumphant. It remains the most common type of ending, even if it can be disdained by some. Far, far too common to provide example.
Specific types of Happy Ending include:
- Happily Ever After - for when just being happy isn't quite enough
- Earn Your Happy Ending - for when the Happy Ending comes after much darkness and angst
- Deus Ex Machina - when the Happy Ending is too easy
- Esoteric Happy Ending - when the 'happy' ending doesn't sound like one
- Surprisingly Happy Ending - when the characters were expecting something else
No examples, please; this is an Omnipresent Trope.