To foreshadow means to indicate or suggest something that is going to happen later, either good or bad.
There are many reasons why foreshadowing is so important. Authors weave this technique into their craft - whether in dialogue, description, or the attitudes and reactions of the characters -- to build tension and suspense to keep their readers engaged until the conflict is revealed. The ultimate goal of this device is to enhance the emotional gratification the reader or audience feels at the end of a story. Good use of this literary tool ties the beginning of the story to the end producing structural and thematic unity.
When it comes to understanding foreshadowing and its definition as it relates to literature, you will find that it always points to the conflict - the driving force of all writing. Without conflict, a story is boring and the reader loses interest. However, all conflict foreshadows itself.
In his book "The Art of Dramatic Writing" Lajos Egri writes, "There never was a night without a twilight; a morning without a dawn; a winter without an autumn; a summer without a spring first; they all foreshadow a coming event."
However, when properly done, this literary device does not give away the ending. Prime examples of foreshadowing in literature include a rain storm in the beginning of a story suggesting something bad is going to happen later and a death of an animal in the beginning of a story suggesting the death of a main character in the end.
Once of the most frustrating experiences is watching a movie or reading a book in which the hero suddenly gets killed by a character who was newly introduced in the story. The reader has to stop and think about the plot and wonder how this could have happened. This is a prime example of when a writer does not use this technique.