Human beings are social creatures, and that means we have in-built mechanisms that protect and nurture society. We have a sense of fairness, and we're usually kind and generous. We also are capable of empathy--we can look at another human being and see ourselves there, or at least see what we might have been had we lived that other person's life.
When a writer creates a story, that writer must establish the reader's empathy with the protagonist. If the audience doesn't connect via their hearts to the hero, they can't sustain the energy required to keep reading the book.
So you always want to go groping after reader empathy, right? That's always a good thing to get? Not always, actually; there's one important exception.
If you're writing comedy, reader empathy can be a bad thing. No one laughs if they believe someone innocent really got hurt.
The film A Fish Called Wanda has a scene where a concrete block falls on and kills a small, yappy dog. The director filmed two versions of that scene, one where you see a lone paw twitching under the massive block, and another where you see the same thing except with blood and guts leaking out. When the movie was shown to test audiences, the “clean” version got laughs. The gory version made the audience go utterly silent. “Poor doggie” was the wrong response, so the tidier death is the one featured in the finished movie.
Humour is very often about rage and pain. Think about Dennis Miller's routines--the guy is furious and he's verbally attacking everything that makes him angry. Now think about John Cleese's skits, many of which investigate all the myriad, humiliating ways in which life hurts. No wonder comedy is tricky; you have to take anger and turn it into someone else's laughter. You have to depict pain and evoke derision, not sympathy. People are basically nice, so this isn't easy.
If you want your readers to laugh, you have to communicate that the comedy didn't really hurt anyone who counts.
“[D]idn't really hurt” means it's fine to drop the loveable protagonist into the piranha tank if she comes out with only a single fish attached to her nose. It's okay for the hero to get frothing mad if he externalizes his anger and goes on an absurd attack; the reader knows he isn't going to have lasting psychological damage from his anger.
“[A]nyone who counts” means if the villain is so nasty we think he deserved his pain, we don't feel bad about giggling at his grisly downfall. If the person who blundered into the wedding cake and came up slathered in icing with a small groom sticking out of her ear is so ridiculous that we have no empathy for her, then we'll happily guffaw at her humiliation.
Which brings me back to humanity's innate sense of fairness. Jim Butcher's excellent articles on writing note that the key to delivering a satisfying conclusion to the reader is to deliver poetic justice to your characters. Those who make selfish or stupid decisions are punished. Those who make wise and selfless decisions are rewarded. Humans really are built to believe in justice, and we love to see stories where our sense of what is right is upheld. We like seeing karma in action.
So when you write comedy, think carefully about how much audience empathy each character has, then deliver no more misery than what the audience believes that character deserves. If you don't provide poetic justice, then no matter how wonderful the rest of your story was, the reader puts your book down with the nagging feeling that something wasn't quite right. It can kill the positive word-of-mouth your writing might have elicited from that reader otherwise.
How have you handled humour in your writing? In your stories, what got the laughs? Did you show ridiculous behaviour, or did you skewer ridiculous behaviour? Did you let the reader recognize something familiar but funny, or did you show them the familiar and then twist all their perceptions, i.e. deliver the equivalent of a punchline? What humour techniques work for you?