I can't speak to Dune because I've never read it or watched any of the adaptations, but I want to add another point to the "movies/media should have SOME humor in them" Discourse.
Having characters joke around with each other, even in tense moments, even in genres that are about tension, even in Very Serious Pieces of Media, gives your characters a sense of camaraderie. And the type of joking they do can get across to the audience how well they know each other and what their relationship is without saying it (or can back up what they say). If they're actively teasing each other and making in-jokes about shared experiences, it shows/reinforces that they're friends or partners who've known each other for a while, they feel comfortable lightheartedly ribbing each other, and they have a deep well of embarrassing/funny moments to draw from. If they're making more general jokes that aren't about the person, but still referencing shared experiences, they may have known each other for a while, but aren't necessarily friends, maybe they're coworkers or classmates or a regular at a restaurant and their preferred server. If they're making more general jokes without references, they probably only recently met and have had generally positive interactions, or they might be complete strangers who are just trying to break the ice.
Going back to the "friends who have known each other for a long time and are comfortable ribbing each other and have a lot of material" for a moment, specifically in the context of things like horror and dramatic epics like I understand Dune to be? When you have characters who joke around with each other like that, when one or both of those characters stop joking? It can also help prime the audience to understand, "Oh shit, shit's getting real now."
Like, think about Merry and Pippin in Lord of the Rings. Both of them spend a lot of time joking around with each other and the other characters, even when they're on their way to Mordor. Both of them lose the jokes the moment things get dangerous, but are back at it when the tension's released again. In Fellowship, the jokes pretty much stop the moment they get chased into Moria and don't come back until they've come to terms with Gandalf's death enough to move on from Lothlorien. They're back to it until they get attacked by the Uruk-hai, then back to their shared mischievousness again once they once they figure out how to convince Treebeard to rally the Ents and attack Isengard and are fully joking around again by the time Aragorn, Legolas, and Gimli catch up with them in the aftermath of the battle.
Then, everything goes to shit. Pippin consistently shows himself to be the kind of person who doesn't quite grasp the potential danger of things and places that he hasn't experienced himself. The combination of that alongside his natural curiosity leads to things like him fiddling with the arrow in the dwarf skeleton that overbalances it into the well it was perched on, alerting the goblins and balrog to their presence. And to him sneaking a peak at the palantir. In the moments after, when Gandalf is readying things to take Pippin with him to Gondor, Merry, who's been able to, if not fully grasp the gravity of what they've been doing, at least trust their companions' assessments, listen to what their saying and read between the lines. And we finally see the seriousness and danger of the situation really sink in for Pippin.
He's seen Sauron, had him in his head, he's not just a vague concept of a Bad Guy off in a part of the world that may not exist for all that it's effected Pippin before leaving the Shire. He's seen how scared Frodo's been, seen the danger he's been in because of the ring, and now there's a possibility that Sauron thinks Pippin has the ring. Even when they left their home, Pippin still had Merry and Frodo and Sam. But then things got too dangerous for Frodo to stay so he left and Sam went with him. Now, things are so dangerous, that Pippin has to leave his very best friend and, after all they've been through, it's hitting him that he might not ever see any of them again.
This is the moment where all the jokes stop. Pippin has moments of joy and happiness and relief and satisfaction. But we never get to see being that mischievous little jokester again. I hesitate to call it character growth, because that phrase usually implies a positive change from immaturity and/or selfishness into a character with more empathy and a sense of responsibility towards other characters. Because I would argue that Pippin already had those traits. He saw that Frodo and Sam were in trouble literally moments after he and Merry ran into them leaving the Shire and he didn't hesitate to help them escape. He fought his best in every battle he found himself in, attempted to avenge Boromir against enemies he knew far overpowered him. The change from the beginning of Fellowship to the end of Return of the King wasn't character growth, it is, and was framed as, a young man forever changed by the horrors he witnessed and experiences, horrors he never could have even imagined before leaving his home, but now weigh in his memories for the rest of his life.
And you get that narrative because of the way the humor is used in Lord of the Rings.