I have recently been spending more time with my baby nephews and niece. Babies are simple. They eat, sleep, poop, explore, and cry or laugh depending on how well the situation supports this survival and comfort [1]. When you observe babies, it's very apparent that we are all just survival programs. Adults just play more complicated, indirect, and longer-term survival games.
We begin as bootstrapped programs that function as follows: (a) feel pain and act distraught when we experience something threatening to survival, (b) feel pleasure and act happy when we experience something positive for survival, and (c) seek more pleasure and avoid pain, and be curious about the environment, presumably to look out for those sources.
Then the program learns rapidly over time, through memory and imitation - avoiding the pain, doubling down on the pleasurable, and exploring to discover more. There is a fair bit of randomness in there too. Many of the learnings are then passed on to offspring through their bootstrapped program and as inputs to their learning, continuing and compounding the learning over generations.
The program is optimized for survival (because only the surviving programs continue to exist), but not for equanimity or happiness. In fact, feeling distraught - worried, fearful, sad, greedy, guilty, or angry - are features of the program that enable survival in their own ways. So if you let the program run its course, you'll likely prolong your survival and propagate, but you will often feel distraught too.
If "you" (which are just subprograms of "consciousness" and "ego" running within the main program) want to instead optimize for happiness, you will have to reprogram the main program and overcome millions of years of strong programming.
This reprogramming takes deliberate and consistent effort and is the basis of several practices like mindfulness, Buddhism, journaling, and therapy. They all recommend a similar pattern:
1. Increase your awareness of your programming, thoughts, and feelings. You can do this through daily journaling, meditation, pausing & reflecting by yourself or with a therapist when you feel distraught.
2. Understand the core reason, need, or belief on why you think or feel that way.
3. Change the core reason, need, or belief when it isn't helping your happiness.
Notes:
[1] The most common aspects of survival are eating, physical safety, social safety, and reproduction.