We can see things in 3-D due the fact the each of our eyes sees things slightly differently. Using the difference between the image captured by the right eye and the left eye the brain can estimate the distance of the objects, that we are looking at, from us.
3-D movies use the same principle. While filming a 3-D movie two cameras are used which are placed apart from each other at a distance equal to the distance between our eyes. When the movie is screened two images are projected towards us. One is meant to be seen by the right eye and the other by the left eye. This is achieved by using the goggles. If you were to watch a 3-D movie without goggles, what you see is a blurred image as each eye is seeing the image meant to be seen by it as well as the image meant to be seen by the other eye.
How 3-D glasses work has changed over time, earlier the two images were displayed in different colors. The lenses of the 3-D glasses were also colored differently and only allowed one of the images to pass through. This created the 3-D effect. The 3-D effect now-a-days is created using other methods one of which is by polarizing the two images in a different way. Each of the lenses only allows light with a particular polarity to pass through. This has improved the quality of images seen by a large extent.