Football would be a nightmare if players were hanging out in the other team's box, waiting for the ball to be hoofed upfield to them so they could tap it into the back of the net. Offside stops this from happening by making sure that the receiving player is not in front of the opposition's defensive line.
this is the commonly-held wisdom on offside, but I’m a little sceptical of it. 7-a-side, 5-a-side and futsal manage just fine without the offside rule (admittedly on smaller pitches). I suspect that 11-a-side would just look different without offside, it wouldn’t be a completely broken game. your best defenders would still have fair battles with your best attackers, and midfielders-midfielders etc
By your description Mandzukic's WC final goal should be offside https://www.youtube.com/watch?v=WzN-ahqULc4
Goalkeeper makes a save, since the ball is rolling towards the goal. If the attacking player touches it, it will be offsides: A player in an offside position has entered active play by "challenging an opponent for the ball" or "gaining an advantage by playing the ball or interfering with an opponent when it has [...] been deliberately saved by any opponent".
The goalkeeper deliberately plays the ball. Immediately afterwards, the attacking player receives the ball played by the goalkeeper - this is not offsides, since "a player in an offside position receiving the ball from an opponent who deliberately plays the ball, including by deliberate handball, is not considered to have gained an advantage, unless it was a deliberate save by any opponent."
https://www.thefa.com/football-rules-governance/lawsandrules...
"A player in an offside position at the moment the ball is played or touched by a team-mate is only penalised on becoming involved in active play by:
...
gaining an advantage by playing the ball or interfering with an opponent when it has:
- rebounded or been deflected off the goalpost, crossbar or an opponent
- been deliberately saved by any opponent
A player in an offside position receiving the ball from an opponent who deliberately plays the ball, including by deliberate handball, is not considered to have gained an advantage, unless it was a deliberate save by any opponent."