In the preface to William Gibson's Burning Chrome, Bruce Sterling said science fiction writers are like court jesters, able to speak truths without offense. "We are Wise Fools who can leap, caper, utter prophecies, and scratch ourselves in public. We can play with Big Ideas because the garish motley of our pulp origins makes us seem harmless."
Science fiction is able to make indictments against us palatable. We can choose either to accept them as truths or dismiss them as empty fiction. Star Trek, we know, wasn't saying that hundreds of years in the future we'll see racism as a social flaw. It was saying that it should be recognized as such back then in the '60s. Every comment on the Prime Directive, every mention of how the people of Earth solved their society's problems, were not speculation on what the future might bring but arguments that something was wrong in the present.
Science fiction's messages need not even be positive, and the genre isn't necessarily one strictly of open-mindedness. Michael Crichton, for instance, couldn't readily be accused of optimism. Robert J. Sawyer, in an address at Laurentian University, explained the difference between authors like himself and authors like Crichton: Sawyer's books do not suggest that technology is a bad thing, something to be warned against. Crichton's books do.
"Now, yes, I am an optimist about the future; I think most science fiction writers are. But the most successful science fiction writer in the world - the one who sells the most copies - isn't. Michael Crichton is, by far, the world's top selling science fiction writer, and yet he's fundamentally an anti-science guy." In fact, Sawyer went on to summarize the plots of Crichton's most famous novels, always ending with "everything goes wrong, and people die."
We enjoy both forms of sci-fi for the same reasons, though. They tell us about ourselves, whether we recognize that immediately or not. Tales of a dystopia remind us that not all scientific pursuits are progress, and they imagine a future's worth of those pursuits run rampant. In Crichton's world, when humanity tries to better itself with technology, everybody dies. And this appeals to people who are concerned about the state of our world today, who see it tracking further away from some ideal. These stories are just as popular - if not much more so - than those that paint technology in a kinder light.