Cube made no extensive attempt to explain what the cube that the characters are confined in is, why it was created, or how the people were selected to be put inside there. The movie remains without any answers.
But Sequels have done that as stated by in the Wikipedia article
The second film reveals that a company named "IZON" is responsible for
the development of the Cubes, and the third film indicates that their
construction and operation has either been ordered or directly carried
out by a non-descriptive "government". The films are alluded to be set
in the future, however, one of the characters of Cube 2 mentions
Muammar Gaddafi, who was alive at the time of filming.
Even in the third film Cube Zero which is prequel to CUBE and CUBE 2 it is mentioned that everyone in The Cube was facing a death sentence and was presented a choice: Go in the Cube with their memory completely erased or be sentenced to death. Only if a person signs the consent form will he or she then be placed in the cube.
However Eric discovers that there is no consent form in Cassandra's file (Cassandra is the main protagonist of Cube Zero and Eric is a watcher outside the cube). That meant that the consent is not always given for all prisoners.
In the end Jax shows Eric his consent form and says he had been put in the Cube not as a victim, but as an observer with his memory reprogrammed so he would have no memory about his past life.
In March 2011, Lionsgate announced it was considering an additional film in the series, tentatively titled Cube 3D(May be a sequel or Spinoff). This movie may explain about why people are kept in the cube without their consent and is there any other type of people in the cube except observer and victim.