From Gretchen Rubin's The Happiness Project:
One reason that challenge brings happiness is that it allows you to expand your self-definition. You become larger. Suddenly you can do yoga or make homemade beer or speak a decent amount of Spanish. Research shows that the more elements make up your identity, the less threatening it is when any one element is threatened. Losing your job might be a blow to your self-esteem, but the fact that you lead your local alumni association gives you a comforting source of self-respect. Also, a new identity brings you into contact with new people and new experiences, which are also sources of happiness.
On enjoying your failures:
Pushing myself, I knew, would be a source of discomfort. It's a Secret of Adulthood: Happiness doesn't always make you feel happy. When I thought about why I was sometimes reluctant to push myself, I realized that it was because I was afraid of failure--but in order to have more success, I needed to be willing to accept more failure. I remembered the words of Robert Browning: "Ah, but a man's reach should exceed his grasp, or what's a heaven for?"
To counteract this fear, I told myself, "I enjoy the fun of failure." It's fun to fail, I kept repeating. It's part of being ambitious; it's part of being creative. If something is worth doing, it's worth doing badly.