If you think of, say, locker #6, it gets flipped open or closed by the 1st, 2nd, 3rd and 6th student, i.e. it will be flipped by student n any time n is a divisor of 6. So locker #6 will stay closed, because 6 has an even number of divisors. On the other hand, locker #25 say gets flipped by the 1st, 5th and 25th student, so it will end up open because 25 has an odd number of divisors.
The only numbers with an odd number of divisors are perfect squares. So the question is just asking: "How many perfect squares are there between 1 and 1000 inclusive?" Now 32^2 might be familiar, since it's a power of 2 -- it is equal to 1024, so 32 is too big, and the answer is 31.
I'd add that in a real GMAT question, when answers are simple integers, the answer choices would always be listed in increasing or decreasing order, and real GMAT questions wouldn't waste time discussing how "strange" the principal of a high school might be, so this is clearly not an official question. I suspect if something similar were to appear on the real test (which seems unlikely to me), the number of 'lockers' involved would be far less than 1000.