You can deconstruct humor, but then it becomes less funny afterwards. It's also very individual, based on experiences and tastes, but I think you get that.
Given that, I'll do what people usually hate. Deconstruct humor.
For the purposes of fiction, I think there are two types of humor, there is situational humor, which comes from the plot and characters and there is humor more like where the plot is sacrificed to make a joke or series of jokes.
The first is a bit more like PG Woodehouse or Jane Austen, I think. And the second is more like Monty Python and the Holy Grail or Douglas Adams.
Of course you have different labels on humor, too, such as wet, dry, whacky, physical, etc.
The majority of stories inserting a joke into the story put it in as *situational* humor. Which comes from the characters. You usually can test this by trying to explain the joke to a friend and they won't get it until they watch the characters and episode. Whereas if you say something about the other type of humor it will come through right away. (Marvin is a depressed robot with pain running up his diodes). Also, situational humor tends to have more in-jokes running through it, such that if you discuss it, then others immediately get it it who've watched it, but others that haven't seen it won't understand you.
42!
The best you can do if you want it funny overall is to mix up your humor. Some of it high brow, low brow, some puns, wet, dry, parody, etc. (BTW, with parody never make it critical to the plot unless it's *that* popular.)
With situational humor, too, I'd also try to blend it in so it's not obvious it's a joke and screaming at the person. Either they get it or they don't and move on.
Now jokes themselves tend to have features: such as reversals, the unexpected, the overly exaggerated, socially outlandish, etc. You can find some examples online. Never steal jokes though. If you do take one with permission, at least save and give credit later.
Figure out why it made you laugh will mean it won't be as funny later. =P And you'll be laughing less often, but making people laugh more. (This is a joke comedians say about other comedians. Seinfeld had an episode dedicated to it.)
Also, you should be aware that jokes tend to be double-edged, as Chapelle pointed out on Oprah a few years back. Often with social parody, there are people who will immediately get it and those who won't. Those who won't will laugh and find solidarity with the other people who won't get it and often run opposite of your aim in making the joke in the first place.
So for example Chapelle had a black-faced fairy in stereotypical black faced clothes making fun of racists, but he was offended when one of his staff members laughed the wrong way because they didn't get it was against racists. And Chapelle didn't know what to do about that.
Personally, though, if you're not going to run social commentary at all, I think bad and worse puns, while universally hated, are safe from all of that. People either really groan and like it, and you're laughing your butt off about how horrible it is and they use them again, or they ignore you or they simply don't get it and gloss over it.
Bad puns such as what country likes eating cat dumplings? Katmandu. <--made that one up myself. I have a love of interlingual puns too. Especially the triple interlingual puns.