At some level, they believe that certain things are sin and are dangerous if they influence others. And not all of their things are wacky. They are things many Christian groups also preach against. Sin can spread. How many times have we looked at others and said "look, they're getting away with it, I might as well too"? Probably we all have. Ever been speeding on the freeway because the traffic around you was too?
And if people are being caught and punished, it does act as a deterrent.
Apostasy is especially dangerous. Ideas can be infectious in ways that other sins aren't. Just because somebody else starts smoking doesn't mean I will. Or because somebody else is having premarital sex, doesn't mean I will. But ideas are different.
Obviously there's drawbacks. Mental torture to those condemned. And for friends and family of those people.
I know JWs aren't perfect. And many do secretly break the rules, but I've always thought that even though most Christian religions teach the same sins, that JWs were far less likely to commit them. Not that they don't. But less likely because of the fear of punishment.