Eyes evolved in primitive micro organisms that first had light sensitive tissue which enabled them to distinguish between night and day. This was a tremendously significant evolutionary step.
So your first assumption is correct; eyes evolved to better observe the habitat environment of the creature.