For the sake of argument, let's assume that punishment has absolutely no effect on whether someone will commit a crime. Even so, there's still a benefit to imprisonment: it separates criminals from society for a period of time, during which they won't be committing crimes against it.