Let's take a moment to discuss the differences between stupid-funny and stupid-annoying humor. It's a fine line between the two, partially due to the nature of funny. Personally, I subscribe to the incongruity theory of humor, which states that you laugh when you realize the incongruity between a conceptual something and the real-life something it represents.
As a lame example, it would be kind of funny if a child took its stuffed animal cat to the vet because only real cats need to see a veterinarian. Now, it would be really funny if the vet told that stupid child that the cat had to be put down.
It's essentially recognizing a situation and delivering a counter-intuitive twist. Normally, the audience sees these twists coming and prepare themselves accordingly. When Charlie Brown tries to kick the football, we all know that Lucy will pull the football away; what we are waiting for is the bald-headed kid's depressing one-liner afterwords. The audience expects to see this as the result, and an extreme deviation from this path would not be funny. Charlie Brown quitting football, while reasonable, would not be funny. Charlie Brown taking out his frustration by beating Lucy within an inch of her life, while not totally unexpected, would also not be (very) funny. Charlie Brown sneaking into Lucy's house and kicking the ball at her during dinner, though, would be much more satisfying because A) it matches the tone of the established pattern (I imagine Lucy with mashed potatoes on her head, saying "AAAUUGH") and B) it is a slight twist on what we expect. Now, if Charlie Brown misses the football and makes his joke, that is still satisfying because we all know that you're supposed to kick a football.
Sometimes, humor becomes stupid. This is mainly because it aims to be universal (or, if you want to be rude, appeal to the lowest common denominator), so it must approach the real-life situation in a way that a lot of people recognize and identify with, but subvert that expectation with a twist that everyone can recognize as incongruous. For example, in Mel Brooks' Robin Hood: Men In Tights, Robin Hood has a short battle with Little John above a stream. When Robin Hood wins the battle and knocks John into the stream, this is expected. Robin Hood is the hero of the story, so of course he won. This is also the way Robin defeated John in literature. Right there, we have the expectation. Because Robin is the hero (and because legend says he does it), we know that Robin will rescue John from the stream when John cries out that he cannot swim. However, in this movie, the stream is barely more than a trickle. Infants would have trouble drowning in this river bed, and this is pointed out by Dave Chappelle before the battle begins. So, when John cries out that he is drowning, the audience knows that he is overreacting. The audience realizes the incongruity between John's perceived situation (drowning in a stream) and his actual situation (rolling in a slightly damp river bed) and laughs, because the character is being stupid.
There are two types of stupid humor: funny and annoying. Stupid-annoying humor occurs when you see the punchline to the joke a mile away and are proved to be right. In the Robin Hood example, most children under the age of twelve will laugh at that joke. They have been exposed to little in the way of clever spoofs, so this simple joke has the desired impact. However, for anyone who has seen Blazing Saddles and Young Frankenstein, this joke just doesn't cut it because we know how much funnier Mel Brooks can be. We know the tale of Robin Hood and Little John, either through our cultural exposure or through Robin Hood: Prince of Thieves, which Brooks is directly mocking, so we know John cannot swim. Even if someone was unaware of the history behind the scene, Chappelle points out the dry river bed. At best, most adults will chuckle and mutter, "Stupid," under their breath. At worst, the adult will roll their eyes and breathe audibly through their teeth.
There are three ways to avoid stupid-annoying humor. The first is to write jokes that are not obviously jokes; if they arrive unexpectedly, jokes are difficult to predict. The second is to write non-topical random jokes. Family Guy is a series that is entirely comprised of these jokes. In a Family Guy episode, Little John would fall in the river and Peter Griffin would say, "This reminds me of that time when I was a lifeguard on Amity Island." The scene would cut to Peter digging sand out of his navel while Jaws attacked swimmers. The scene would then cut back to the river bed, where John would be lying in the river and say something like, "So...you're not going to rescue me? Really...? Are you sure...? I could, you know, take off my shirt and wriggle in the mud for a minute...no? Fine. Screw you and your gay men." "MERRY men!" "Whatever!" And then the scene would cut to commercial and nobody would reference the riverbed again (Side note: I just wrote ten minutes of Family Guy script in about thirty seconds. It's not hard). Random non-topical jokes are stupid. They are annoying. But, thanks to their utter randomness, they do strike a lot of people as very funny. Personally, I hate my Family Guy joke. Hate it. Somebody, though, will like it and think that I stole it from an episode. In some ways, random non-topical jokes are worse than stupid-annoying jokes, because they do not fulfill the promise of the premise. To return to the Charlie Brown example, a random non-topical joke might have Charlie Brown run toward the football, only to find Lucy having sex with Larry King, probably with some reference to him being a blockhead. See? Not funny, and it might make you ask youself WTF? Basically, if the punchline makes no sense whatsoever, it's a random non-topical joke.
Stupid-funny humor can be differentiated from stupid-annoying humor and random non-topical humor by the punchline. The setup is still broad enough to be recognized by most people, but the punchline is not what is expected --- and here is the key --- but still recognizable as belonging to the situation. To return to my lame example, it would be kind of funny if a child took its stuffed animal cat to the vet because only real cats need to see a veterinarian. That represents the real-life situation (going to the vet) and the incongruous aspect of the situation (the stuffed animal). Stupid-funny humor takes this predictable and universal premise and adds an extra twist. In this case, the stupid child brings his stuffed cat to the vet and the vet says that the cat is living in agony and will have to be put down. By adding the unexpected twists of the vet playing along with the kid and, at the same time, being a sadistic asshole, this joke becomes stupid-funny.
Well, at least I think so. Now, this gives you an idea of where I land on the sliding scale of humor.