One of the most creatively sustained, productive times of my whole life came at a time when I was highly happy, very busy and superbly functional. I did have this feeling that at the time that I had a tiger by the tail. I did feel obligated to take the good times I was having for the ride it deserved. When it ended, (as I knew it must,) for quite some time afterwards, I was almost drunk from the high of having been able to experience and accomplish so much in such a relatively short period of time. (about 16 months)
Later, I did some experiments to prove to myself that mood (pleasant or unpleasant) doesn't seem to have much effect on my ability to have a creative idea or an inspiring, meaningful experience. I proved that to myself by keeping track of how I felt and rating my relative performance for a whole month. Encouraged by my results, I then went on to debunk many other of my own assumptions such as "I don't have the money to..." and "I can't do this because I'll starve..."
My assumption that got debunked was when I felt "bad," my performance suffered. But that wasn't true - I produced and functioned, without feeling up to snuff at all, even when physically sick. (Although my functioning was marginal at times because when I felt bad, I purposefully cut out many options. But I did the "necessary" ones and still got to experience surprising encouragements anyway, despite having lousy days and often being in a bad mood.) It was surprising how my original assumption of, "I must feel happy-healthy-comfortable in order to be creative" was only a bad mood playing tricks on me!
It appears that this assumption works in the opposite direction for many. Do people merely become creative when they are feeling melancholy? That's not true - for me. It's not true for other people so commonly that Barbara Sher has outlined that same discovery as an exercise in multiple books - I think it was first in her book: "Live the Life You Love."
However, I did read somewhere in brain research that when we feel emotionally affected in a bad way, the body exudes some mitigating coping precursor in the brain that causes us to think about what is happening to us. This causes us to carefully reconsider the effect of our previous actions so we can make what will hopefully be a productive improvement in our circumstances.
As my mom used to ask, "Why does the most beautiful music so often sound so sad?"