Stainless steel is stainless because it is doped with metals like chromium and vanadium. Chromium and vanadium oxidize quite readily. This oxide forms a stable, airtight seal which protects the inner steel from corrosion. If the oxide layer is scratched, then the chromium and vanadium that are exposed oxidize, in effect resealing the breach.

Ordinary steel is not resistant to corrosion because iron atoms do not pack together as effectively as chromium or vanadium. As a result, oxidation causes distortion and swelling of the steel, which makes it prone to further corrosion. This can be seen when rusty steel rods used in reinforcing concrete will actually split the concrete around them during the rusting process. For stainless steal to resist corrosion, its important for it to have access to oxygen. Underwater, for example, stainless steel will readily corrode without oxygen accesible to react and form the oxide.

Stainless steel was discovered by accident by Harry Brealey in 1913 while he was experimenting with making new alloys for gun barrels. When he found that one particular steel alloy was resistant to corrosion, he marketed the material in cutlery.