Do you have to be miserable to be a good writer?
I think the answer is no, but sometimes it helps.
What brought this on was reading two books by Shirley Jackson, who is best known for her short novel, The Lottery. I read The Haunting of Hill House, which is a horror tale but the source of the horror is as much the people who decide to stay in the house as it is in the house itself, and We Have Always Lived in the Castle. The latter is a first-person narrative by a young woman who is delusional and quite evil, yet Jackson skillfully gets us to like her anyway.
I didn't know anything about Jackson, but it turns out she died at the age of 48 of heart failure probably brought on by a combination of alcoholism, obesity, and addiction to speed. The Wikipedia entry for her says she suffered from various neuroses throughout her life. Toward the end, she was agoraphobic and wouldn't leave her bedroom. At least she was able to turn her experience with misery into books that live on.
She joins a number of other outstanding writers who were unhappy, depressed, or ill, and certainly it seems that alcoholics are over-represented in the world of authors. However, there are also plenty who had less traumatic lives and wrote well...although it's harder to think of as many examples.
Maybe the secret is being able to mine such unhappiness as we have had, whether it was dished out to us in quantities large or small (as well as mining the happy times as well, of course). Probably you have had enough unhappiness to work with already, now you can be happy. If you're not sure how, starting tomorrow I'm starting a series of posts on just that topic.