When you set something up in a story the audience has the expectation that it will be paid off later on in the story.
A setup without a payoff will tick off an audience.
A payoff without a setup most often results in disbelief – an audience hardly ever “buys” a story element that comes “from out of the blue.”
Setups should not be obvious…most times, the subtler they are, the better the result; the more irrelevant in appearance the setup, the more satisfying the payoff.
But the setup also has to make an impression so that it’s remembered when the payoff does arrive.
In comedies, the setups can sometimes be “in your face” but they better be really, really funny.
In GOOD WILL HUNTING an MIT professor leaves a complicated mathematical problem on a chalkboard challenging his students to solve it by semester’s end.
Later that night, the school janitor, Will, works out the solution on the board.
Next day, everyone wonders who solved it.
Since we know who did, we’re setup to keep wondering what happens when they find out…we’re left in anticipation.
The payoff comes when the professor leaves an even more complicated problem and catches Will writing on the chalkboard. He chases Will away thinking he’s purposely sabotaging the mathematics with gibberish.
Moments later, the professor realizes that Will’s “gibberish” is actually the solution to the problem and runs hell-bent for leather trying to find him.
It’s a delightful payoff – the janitor is smarter than the holier than thou MIT professor’s pet pupils, and probably the also the professor.
How much time passes between the setup and the payoff is a matter of timing, but what comes between the two must also have relevance to the story and/or its characters.