It's a very basic principle: If someone is immobile, sitting and only resting, not doing what they're supposed to do, they may become deeply depressed and unhappy people.
If you go for your quest in life, you may become very fulfilled and happy even when failing to obtain any end goals.
There are of course no guarantees or strict rules in life, so are just very general cause-and-effects in play.
We're happy as long as we're going vaguely where we know we should be able to, to get what gives us satisfaction