Some character types are common across anime series. In series with larger casts, each character often embodies a "type" which becomes the foundation for their character. One of the "types" is the megane (literally "glasses-character"). In many cases this character is the brains of the operation, but in other series, the complete opposite is true. Eyeglasses alone cannot determine which character will turn out to be the "smart" one, but subclasses of "glasses characters" have distinctive roles in anime.
The first major grouping is scientists. Scientists often wear labcoats and wear glasses. This is necessary for SCIENCE!
The second grouping is the "cool and smart" type. Often present in school anime, these characters are often calculating and scheming. In some cases, these characters also end up playing the "voice of reason" within a group.
For villains, glasses can make a character seem distant, detached, and mysterious. In the case of Gendo Ikari from Neon Genesis Evangelion, it also serves to make him seem somewhat inhuman, since his eyes are often covered.
Last but not least, we have the otaku character. Obsessed with their hobby, be it video games, anime, manga, or collectibles, these characters are often the socially awkward character in a school-based anime.
Glasses characters can be said to be a stereotype in anime, however there is a wide variety within this category. A glasses character may be wise, or intelligent, or scheming, or SCIENCE-ing, but they may also do none of those things, or be terrible at them (often in a humorous turn of events). Glasses characters are everywhere in anime, and variations between them can be vast.
Hope Burns Bright