On the topic of what makes a comedy funny, I think the biggest thing is the lack of change in the character. I realized this while watching Dumb and Dumber.
In Dumb and Dumber, you watch these two characters go on this journey. Really, it's the hero's journey, and when they come out the other side, unlike a hero, they are unchanged. They even come dangerously close sometimes to self realization only to go back to where they were before. Self realization I think is oftentimes the killer of comedies.
In plays, a comedy is a play whose structure goes from organized to chaotic. As such, Mid Summer Night's Dream, Tempest, and Taming of the Shrew are all comedies. There are even arguments that, despite its tragic contents, Romeo and Juliet is even supposed to be a comedy. Organized familial separation, forbidden love, war, chaos, suicide. Seems pretty funny to me? Perhaps ironic. At any rate, I was thinking about this formula as it applies to some of my favorite comedies.
Other comedies exemplify this. In UHF, daydreaming Weird Al doesn't learn to control or stop his daydreams. Rather, the world around him is affected by his daydreams, and his girlfriend joins him. More chaos.
In Monty Python and the Holy Grail, absurdism is the name of the game. Arthur never wises up, the knights never gain a greater courage. They are the same throughout the entire movie. In the end they're all either killed or... arrested. Not only do they not change, but the consequences aren't even contextually tied to the actions. Pure chaos.
Billy Madison. This one is a bit of an oddball. For as crass as Adam Sandler is, in every one of his movies, the main character goes from being a real jackass to learning some serious life lessons and turning out ok. Billy Madison is no exception. His characters seem to be tragic characters in that they go from being simple and chaotic to complex and organized. However, the chaos seems diverted from the main character to his surroundings. I suppose there's probably some deep psychology here, and I wonder if Mr. Sandler's even aware of it. At any rate, Billy Madison goes from being a lazy booze hound mooching off of his dad's estate to an educated man seeking a career in education. Organized. But the surroundings: at the end of the movie you have a busdriver making out with a penguin, a large black woman kissing a neurotic psychopath that barely saved Billy's life earlier in gun induced awesome, a kindergarten teacher suckin' face with a resurrected clown, and a creepy barbaric overloud lunch lady makin' out with... someone. Memory fails me. Chaos differed. There is no less chaos in the world, probably more, but it's a result of the main character's actions.
Same goes for TV shows. Would South Park remain funny if Cartman was ever a nice guy? How about Family Guy? What if Peter became educated and got a decent paying job? Totally lame. Or how about if the aliens in Third Rock from the Sun every actually understood why and how earth works the way it does? They'd all become dramas. Stories of changing and dynamic characters. Chaos to organization.
Of course there are some translation issues with this method, and their should be. if anything ever becomes formulaic, it loses the thing that makes it interesting. Like with Billy Madison: it's a funny movie. It's a comedy, but his character evolves in a tragic way. Or how South Park has some dramatic elements, like how for awhile Kenny actually was dead, and the kids grieved his death, or once we observed Cartman feeling the sting of rejection after a girl only used him for his intellect. These issues mostly arise from rethinking these concepts and their application, but the general principle applies.