Fantasy and science fiction are perfect vehicles for humor, and better with it than without. Given that all imaginative fiction is imagined by humans from Earth — any that you will get to read or watch, anyway — it is always really about the world we live in. Ironic distance and satire come with the territory.
Not all works of sci-fi and fantasy follow this path, of course; some writers, and some audiences, are inclined to take things dead seriously, and while this can be fine — “The War of the Worlds” is not a laugh riot — it can also lead to suffocating self-importance and a lack of fun. This is why the best contemporary “Star Wars” for my money is “Lego Star Wars,” and not the live-action franchise spending heaps of money to tell remarkably similar, not especially moving stories of Empire vs. Rebels/Republic and of parents and offspring (and offspring’s offspring) looking at one another from opposite sides of the Force. (The series works better with “Flash Gordon” as its lodestar than “The Golden Bough.”) “Star Trek” had this, centered around the worn-in double act of William Shatner and Leonard Nimoy, with its alchemical mix of overacting and underacting. But the best “Star Trek” movie is still “Galaxy Quest,” which has no problem sending up sci-fi tropes while remaining exciting and touching.