They work somewhat the way an old-fashioned stereopticon viewer (holding two slightly different photos) works.
Each eye focuses on a separate image, but the brain combines them into one image that gives the illusion of depth (the third dimension) in addition to width and height.
It does this by matching up the similarities and adding in the small differences. The result looks like what you see when you look at a solid object from the two slightly different angles of your two eyes.
The first pairs of random dot stereograms, with images embedded in dots, that can be seen only by people with good depth perception, were produced in 1959 by Dr. Bela Julesz; twenty years later, Christopher Tyler, his student, found that patterns could be arranged in a single image to get the same effect.
The ability to see computer-generated 3-D images depends on having healthy vision with both eyes working smoothly together, and the images can be used as a test or exercise.
Vision problems that can interfere with depth perception include amblyopia, or lazy eye, and strabismus, informally called walleyes or crossed eyes.