Your eye lens uses refraction to direct and focus images where it wants them to be. However, sometimes things go wrong. People who can see properly have round eyeballs. People who are nearsighted or farsighted have slightly egg-shaped or elongated eyeballs. This is where eyeglasses come in handy.
Eyeglasses are really just another type of lens.
By carefully measuring how your eyes work, the eye doctor can make a set of lens which refract the light even before they get to your eyes. Essentially, the light which reaches your eyes is slightly pre-focused and then your eyeball does the rest of the job. Proper eye care is very important and you should get them checked at least once a year.