An example (Latin exemplum, the shorthand e.g. stands for exempli gratia, which means for example) is a short story, or an anecdote. This story is told to illustrate something else, like an idea or a concept.
In the Middle Ages, preachers and priests used examples in their sermons. They did this to explain things from the bible. They also did this to explain to all those people (that were incapable of reading) how they should lead their lives, as a good person.
Examples help illustrate a point.
The phrase "make an example" is sometimes used, when a person is harshly punished for others to see. This is done to keep other people (especially the person's peers) from doing the same thing that got that person into trouble.