Offside is a rule in soccer to prevent unfair advantages for attacking players by ensuring they do not position themselves closer to the opponent's goal line than the second-to-last defender when the ball is played to them. This rule helps maintain the integrity and fairness of the game by promoting balanced competition between teams.