You all know how bad writing is often unintentionally funny.
It is a hallmark of the really inept writer that when he/she tries really hard to be dramatic... or profound... or (God help us) "steamy"... the reader breaks out in loud guffaws.
On the other hand, being deliberately funny is not easy.
What makes fiction comical? What is funny?
1. Laughing at unpleasant things. Every culture and era has its taboos and anxieties.
The most basic form of humor centers around aggression and injury: the pratfall.
2. Making fun of human weaknesses. (Pick one...)
Humor has its own peculiar form of logic. It's great when a joke starts with a setup, goes through a series of elaborate steps, and then climaxes in a payoff or punchline. Start with a simple joke, and the more you can build on it, the funnier it gets.
I also think that a sense of humor is important even if you're not a comic writer, or even if you're not trying to write funny.
Why? Simple. Because a writer with a lacking (or non-existent) sense of humor won't notice when he's writing "unintentionally funny" - and is thus more likely to make a fool of himself.
I could quote many examples of writers of that kind... but they would only get mad at me. (That's another drawback of not having a sense of humor: high blood pressure...)