A vehicle's oil has to be thick, but not too thick. It is important that in the winter, the oil be thin enough to allow for the engine to start. But when the engine is warm, the oil must be thick enough to lubricate properly. That's where the numbers come into play.
Neither number corresponds to an actual 'weight,' even though that is the term most people use when referring to motor oil. The viscosity (flow resistance) is tested by allowing a small amount of oil to flow through an aperture. The quicker the oil flows, the lower the rating numbers.
The first number rates the viscosity of the oil at a temperature of 0 degrees F, mimicking cold winter weather, which is why the 'W' designation is added at the end of the first number. The second number repeats the test at 210 degrees F., or normal operating temperature for a fully-warmed engine.
The 'W' rating can be 5, 10, 15 or {20;} lower numbers mean the oil is thinner in cold temperatures, necessary for icy climates. The second number rating (meant to represent normal operating temperature of an engine) can be 20, 30, 40 or 50. Warm-weather spots usually require oil in the upper end of that range that can handle extreme heat.