It will prevent infliction of future negative utility (or at least it is intended to).
So will punishing future crimes. If people see that criminals have a history of being punished in their past "for no reason", they won't wan't to become criminals as much.
Here's an edited version of a puzzle from the book "Chuck Klosterman four" by Chuck Klosterman.
When should you punish someone for a crime they will commit in the future? Discuss.