The main setting of Ender's Game is the Battle School, where gifted children are challenged and prepared to lead armies against the alien Buggers. This setting is not a warm and friendly school, but a harsh military environment; the children are largely unsupervised and deliberately pitted against each other by the teachers. This form of teaching forces the children to create their own coping skills and methods of survival.
"Most of you aren't worth the price of bringing you up here to Battle School because you don't have what it takes. Some of you might make it. Some of you might be worth something to humanity. But don't bet on it."
(Card, Ender's Game, Google Books)
Throughout the book, Ender is subjected to difficult personal tests, some self-imposed (the Giant's Drink) and some created for him personally (battles against two armies at the same time). He perseveres because he hates the idea of losing and being broken, and the lessons he learns make him ideal for leading the real army in the final battle against the Buggers.