Foreshadowing helps keep the reader interested and engaged. If foreshadowing did not exist, then the reader would not need to pay attention to the story as closely. For example, if the time is mentioned in passing in an early chapter. That time may become significant in later chapters as the time of a significant event. The reader must pay attention to the details of the story and remember them in the greater context of the story to help it make sense.
Authors often use foreshadowing to help the reader "get there" and figure out the story. Authors will drop details that foreshadow the rest of the plot, and readers discover the greater meaning as they go along. Mystery authors often do this with whodunit stories. The author must be clever and not divulge too little or too much foreshadowing, to keep things interesting.
Sometimes authors will use foreshadowing in the context of a red herring, to intentionally misguide readers. Authors use this tactic to create an element of surprise for the reader later on in the story. For example, early in the story, the author may divulge small details about a character to make the reader think that the character is a villain. Later in the story, the author may reveal those details as part of a greater context to show that character to actually be a hero.
Foreshadowing can also be part of a prophecy or omen: a prediction of future events. This type of foreshadowing can play a very significant role for the characters. For example, before going on a quest, the hero visits an oracle who tells him that as long as he remains honest, then no harm will befall him. The reader then knows that this prophecy is now part of the structure of the world that character lives in.