"Doctor Who" is often very, very funny, but I take your point. As somewhat suggested above, comedy is hard.
I imagine that part of its general absence from sci fi is that the strand of believablilty is already so stretched. As soon as there's humor, the whole story stands the risk of being instant self-parody (for example, the seatbelt scene at the end of NEM, which was done for a single cheap laugh). But there remain many good opportunties for humor in characterization
, and so we at least have such nuggets as Mudd and "It's . . it's green."
Anyway, the lack of real humor in modern sci fi likely results from the fear of risk. There's no shame in that; again, comedy is hard work, best left to specialists. The stakes are even higher these days because everyone is creating such dark futures; the resulting contrast is higher if even the lightest joke is introduced.
I don't want get all academic, but such an outlook is an error. Shakespeare's best laughs come in the most dire scenes. Of course, we have few Shakespeares today. Likely none.
I'm rambling, but one final example: I think that "Tribbles" is rather unfunny, with one exception -- when Kirk is questioning everyone about who started the fight on the space station. That is character
humor, rather subtly played, and I laugh at it still.