The Ames room works by setting up a conflict between two things that our visual systems has learned to expect about the world around us:
Expectation #1 - Most human-made structures are composed of right angles
Expectation #2 - Most people are roughly the same size (and humans don't tend to change size over short time periods).
By making a room with a strange geometry that appears to be in line with Expectation #1, you can trick your visual system into abandoning Expectation #2.
Basically, your visual system says "Well, those folks are walking along a wall, and walls are usually flat, so since they are changing size on my retina, they must be changing size in real life."
In reality the people are changing size because they are getting farther away, but the room is set up to hide the changes in depth. Hence the illusion.
Worth noting though - This illusion only works when it is being viewed through a peephole. If you let people see the room with both eyes, or through a slit that allows them some side-to-side movement, the additional depth cues wreck the illusion. Basically, by giving your visual system more information about depth, you can see that Expectation #1 is being violated, which leads to you reinstate Expectation #2. (source)