Glasses are a lens which focuses light coming in to your eye. Think about how a telescope works: you have a lens that focuses light down to the size of the eyepiece, which then changes the focused light into a beam for your eye to see. This lets you see things that are very far away. Your eye has a similar lens just behind your pupil, but given time or conditions it may come out of focus on its own. However, with a pair of glasses, you are creating something kind of like the telescope; the glasses are the front lens, the lens in your eye is kind of like the eyepiece. With the right lens pair, everything comes into focus. This is where the eye doctor comes in; his specialty is that he knows which kind of lens is needed to match the lens in your eye so that the two work well together.