This movie is a remake of a movie based on a book that was inspired by the real-life Stanford prison experiment. The experiment at Stanford ended early as both the guards and prisoners took their respective roles too seriously. The experiment will never be redone because, although it was deemed ethical at the time under the later-amended rules of the American Psychiatric Association, any research done must not physically or mentally harm the participants.
The trivia item below may give away important plot points.
Although some similarities exist with the real Stanford Prison Experiment - e.g. it was really terminated after only six of 14 days due to the guards going power mad etc. - there are many more wildly different events in the movie. No-one was physically harmed at all in real life, let alone murdered, raped, savagely beaten, etc.