Based on the other answers, I'm going to offer this as an example. Please bear in mind that this answer follows the old adage "sometimes a little inaccuracy saves tons of explanation".
Let's say you have two RS485 devices that are electrically isolated. You connect up the A and B lines as normal. However due to stray capacitances and other electrical engineering voodoo, one of the devices is floating at 3000 volts higher than the other.
No problem right? The receiver just sees lines A and B coming in at 3000V and 3012V, it picks out the 12V differential which is within spec and off it goes?
Well because of the stray capacitances, the devices aren't actually 100% isolated, and so the receiving device actually sees 3000 volts on the A and B lines relative to its own power supply. The RS485 chip it's using is only rated to provide 2500 volts of isolation, so the incoming voltage is able to jump that chip and fry some other part of the circuitry. The available current at that voltage is tiny so you wouldn't even see a spark, but it's enough to cause ESD-like damage to other ICs in the circuit, stopping them from working properly.
By connecting a GND wire between both devices, the 3000 volt difference will be removed by that same microscopic current travelling through the GND wire instead of the other ICs in the device, and the 3000 volt offset on the A and B signalling lines will disappear.
In some ways the GND line is serving a similar purpose here as a pull-down resistor, ensuring that all the signal lines are at known levels rather than randomly floating all over the place.
Yes, the RS485 spec only looks at the difference between the A and B signal lines, but each device also has a maximum permitted voltage between its own power supply GND and the signal lines. Stopping that particular voltage from going out of range is done by ensuring all the device's GNDs are the same, so a GND wire between all the RS485 devices does just that. Yes in theory electrically isolated devices won't have massive voltages between them, in practice it seems isolation is not always perfect so don't count on it.