Before the J.J. Abrams 2009 Star Trek reboot movie became the most successful film in the long-running sci-fi franchise, the biggest Trek film of all time in terms of the numbers wasn't an outer space epic, but instead, a time-travel comedy.

From 1986 until 2009, Star Trek IV: The Voyage Home held the box office record as the most successful Trek ever, which is significant because it's the only film in the series that values jokes over action. The Voyage Home represents a part of the Star Trek formula which tends to get overlooked: the reason the franchise is so great is that it's often very funny.

"I wasn't a Star Trek fan when I came to it," Nicholas Meyer tells SYFY WIRE. "And when I saw the first movie [1979's Star Trek: The Motion Picture], I thought, wow, I guess there's no joking in space!"

Meyer, of course, is famous for writing and directing Star Trek II: The Wrath of Khan, co-writing aspects of Star Trek IV, and directing and co-writing Star Trek VI: The Undiscovered Country. He was also a consulting producer on the first season of Star Trek: Discovery, and is the author of three Sherlock Holmes pastiches, most notably, 1974's The Seven Per-Cent Solution, which humorously pairs the great detective with Sigmund Freud. In fact, it's in the unexpected mash-up where much of Meyer's humorous instincts work so well. The vast majority of the gags in The Voyage Home rest on the idea that people from the 23rd century would hilariously not be able to blend in with people from 1986.

Video of Star Trek IV scene

"If people are fish-out-of-water and confronted with objects or customs with which they are unfamiliar, it's likely, if not inevitable that they'll make some hair-raising mistakes. In Star Trek IV, they got confronted by a lot of off-color-language, and Spock has to explain it's just in all the literature of the period."

This means it's funny to have Spock and Kirk use profanity way more in The Voyage Home than they did in the original show, primarily because they're trying to blend in. But the Meyer wrinkle is that they swear incorrectly. When a car almost hits Kirk on the streets of San Francisco the driver calls the Starfleet admiral a "dumbass," to which Kirk retorts "Well, double dumbass on you!" Meanwhile, Spock spends the entire movie putting "hell" and "damn" in front of nearly everything he says, rendering each expletive absurd. Having a stoic, almost robotic alien swear constantly is way funnier than if one of your friends is doing it.

"One of my idols is the writer Tom Stoppard, and Stoppard says the first thing he looks for is the jokes. I think that idea legitimized my inclination to put in jokes," Meyer explains. "So maybe that's how I justify putting jokes into everything."

While The Wrath of Khan is considered to be the most dramatic and affecting of all the Trek films, it also sports scenes in which Bones jokes about his acting chops, Spock develops a humorous code-system, and we learn Kirk used to flippantly cheat on tests when he was a student and pass it off as "original thinking." All of this prevents The Wrath of Khan only being about a wrathful guy named Khan. And Meyer thinks there's something profound in using humor in other genres is that it prevents a story from being flat.

"Humor is a protest against a kind of one-dimensionality," Meyer explains. "If the movie is a scary movie it's a scary movie. If it's an action movie it's an action movie. Jokes can prevent things from being stale."

Video of Spock quotes Sherlock Holmes

Is humor the only way to save a character like Sherlock Holmes or Spock from being too serious? In Star Trek VI, Meyer insinuated Spock is a literal direct descendant of Holmes when Spock refers to his "ancestor" before delivering a famous Holmes axiom. This moment works from a story perspective in Star Trek VI, but the idea that Spock is part of Sherlock Holmes's family tree is also a nice, sly gag. After all, Spock is half-human, so in theory, these two fictional worlds could be one and the same.

"Humor makes things human," Meyer insists. "Or at very least relatable. Even in King Lear, there is humor. After Gloucester has been blinded he says 'do you know me my lord?' and Lear says 'I recognize your eyes!' And that's the stuff just pulls you right down to Earth."