I’m going to answer the question backwards.
Why do plot twists happen? Because something defies our expectations, right?
So the key to a plot twist is less about the big spin, and more about effectively establishing expectations.
The fact that a character does something evil isn’t shocking, it only becomes shocking because we were so sure that character was “good.”
The same is true for the rules of the universe, which you might subvert for a plot twist. (For instance, The Village–OMGoodness, they were in the modern era the whole time!)
Here’s the kicker: plot twists work best when, on some level, your audience knew it was coming the whole time. If only they had known how to pay attention, they wouldn’t have been surprised at all. Without subtle hints through the course of the story, a plot twist will feel basically random–you could just as well have a bear come out of the woods and eat everybody.
Think of it this way–that character didn’t suddenly become bad, they were bad the whole time. The narrator simply convinced us they were good for a while.
And that balance comes only with practice, and a good editor. Enough hints that the twist clicks, but not too many that everybody can predict it before it happens. (For what it’s worth, if you’ve done this well, about 25% of your audience will predict the twist before it happens.)
We call it a “plot twist,” but, ironically, look to your characters and your universe. That’s where you establish expectations, and that’s where you’ll find the deepest wells for great twists.