Authors use the literary technique foreshadowing to provide hints about upcoming events in the plot. The use of foreshadowing creates dramatic tension by building the reader's anticipation about what's going to happen next.
Authors often use foreshadowing to hint at the outcome of the conflict, or the main problem in the story. Foreshadowing is often subtle, such as storm clouds on the horizon suggesting danger is coming. For instance, as the Lexiconic website points out, one of the boys in "Lord of the Flies" rolls a rock down the hill. The rock goes from the light of the hill to the darkness of the jungle, destroying foliage along the way. This foreshadows the boys' descent from civility into savagery.
Mystery writers often use foreshadowing to make their stories more believable, according to Open School. These authors leave clues for the reader along the way so the resolution of the conflict creates a feeling of acceptance in the reader. Without these clues, readers may feel as if the resolution is a cheat, as if it came out of nowhere because the writer did not know how to end the story.
Foreshadowing is not always subtle. In "Romeo and Juliet," the heroes discuss their desire to die rather than live without each other. Of course, that ends up being the conclusion of the story.