Did you actually think I had an answer to that? OK, well, I sorta do, but I think there are many ways to do it.
Dystopia and, it's converse, utopia, are two of the most common subjects and themes in science fiction. Even when novels don't make the dystopia itself a subject, the setting might well be dystopic in nature. Firefly is a great example of doing this well. The first dystopic novel I ever read was George Orwell's 1984, which I imagine would top the list of many dystopic SF classics. One of the earliest dystopias I really appreciated was John Brunner's “The Sheep Look Up.” It was written in the 70s, and was a scarily prescient look at the future environmental crisis. It did get a few things wrong – we are struggling more with climate change than we are with air pollution, but a lot of what he wrote has come to pass. One of the more interesting things I remember about that novel was that elected officials weren't from states or geographic districts, but from corporations.
The secret to writing dystopia well is to extrapolate logically from our dystopic present, with believable and imaginable steps along the way. John Brunner extrapolated trends in US governance and environmental policy. Octavia Bulter wrote what I would say was the most believable dystopic novel I'd ever read in “The Parable of the Sower.”. She was really good at this. She extrapolated current (at the time she wrote it, and worse now) economic inequality to it's logical result. In some ways, the further in the future you are trying to predict, the less accurate the extrapolation is going to be. In some ways, “The Handmaid's Tale,” by Margaret Atwood is another good example. The scenario of a staged terrorist attack, and religious fundamentalists taking over somehow doesn't seem all that farfetched.
But there's more than just the mechanics of writing a believable dystopia. What's the point of writing a dystopia anyway? For me, it feels like it's a warning bell, telling us to look at where we might end up if we keep going in the direction we're going in. It gives writers a chance just to play with the possibilities, and explore what characters do with the exigencies of dystopic life. And, my favorite reason, is to write about how we can emerge from dystopic futures, find hope and a new way to live. In that way, I hope that it finds us able to emerge out of our dystopic present.