Generally, the function of foreshadowing is to build anticipation in the minds of readers about what might happen next and thus adding dramatic tension to a story. It is deliberately employed to create suspense in mystery novels, usually by giving false clues or “red herrings” to distract readers.
Moreover, foreshadowing can make extraordinary and bizarre events appear credible as the events are predicted beforehand, so that readers are mentally prepared for them.