>>1199076WD40 displaces water, hence Water Displacement formula number 40. It's purpose was originally used to prevent corrosion in tanks (specifically thin walled rocket tanks) to mix with water, force evaporation of the water, and leave a thin, protective, oily film.
The properties of WD40 was eventually realized to be a relatively useful but mediocre general purpose spray for penetrating, degreasing, derusting, lubricating, and protecting. There are better job specific aerosols but WD40 makes a decent spray at a wide range of tasks. People even use it's combustible nature to seat automotive tire beads. WD40 though is a petroleum distillate though, so avoid contact with rubbers and plastics, even carbon composites because carbon is a form of plastic.