That's an extremely broad question, but here is a nutshell answer:
My unhappiness came from a combination of crippling self-obsession, demands and expectations of myself and others, materialism, cognitive distortions and bias, pessimism, negativity and other unhelpful thinking patterns, and essentially having a life centred on me and my image and ambitions and security rather than on constructively contributing to the world. My identity was tied up in the world, which was a catastrophe. It needed to be completely replaced with an identity based on spirit.
The answer was a combination of mental rewiring, moral inventory, confession, extremely thorough amends, high doses of forgiveness, and the complete restructuring of my life onto a basis where I was focused on total surrender to the Higher Power and service to others, in AA and outside AA, but chiefly through sponsorship of others to help them wake up the way I'd been woken up.
I achieved that through the Twelve Steps in AA, but it was not instant, and it took more than one trip through the Steps. Also: not all trips through the Steps are the same. There's a lot more that can be said, but that's enough for now.