The rule was created to prevent offensive players from "cherry picking" near the opponents' goal. Without the rule, offensive players could hover near their opponents' goal even when the play is on the other side of the field, with the hope of a long pass and an easy goal. The offside rule still allows for the chance to score.
It's also important to note that offside applies at the moment the ball is passed, not at the moment the ball is received. Therefore, if the offensive player that will receive the pass is "onside" at the time the ball is passed, but then runs behind the unsuspecting defender before receiving the pass, the receiving offensive player is not offsides.