So, I thought this was unlikely, but then again...
The most likely scenario I can think of is a goal kick, where the attacking team do that thing where they all stand close together near the half way line. The kick is taken, and one attacker breaks early, but realises the ball isn't going to reach him, so stops, expecting to rejoin play when the attack progresses.
A defender makes fantastic contact with a header, and it powers all the way back to the keeper. The keeper runs to the ball to immediately hit it back, so most players stay in the cluster. He kicks, but it's a muddy day and he slips and falls to the floor, with the ball just rolling towards the penalty spot. He's not injured, so the ref doesn't stop play, but he's a bit slow getting back up, as he's disoriented by the surprise fall.
Most players were backtracking slightly, expecting a long kick, but the player who was in an offside position started running back when the ball was headed. He's was still just off when the keeper kicked, but is now the only player moving forward at pace in the right direction, and when he sees the keeper slip, he continues his run and is the first to reach the ball.
An indirect free kick could then be awarded on the penalty spot for offside.