According to the WD-40 Company, the name "WD-40" originated in 1953 when the product was first developed.
The company, originally known as the "Rocket Chemical Company", was trying to design a protectant for metal parts on rockets to prevent rust and corrosion by displacing water... hence the "WD" for water displacement.
The "40", on the other hand, indicates that the formula (still in use today, by the by) was the 40th attempt to get it right!