Iron oxide, commonly known as rust, forms as iron corrodes in an oxygen environment. Iron is especially eager to bond with oxygen, which is why pure iron is rare on the earth's surface. Corrosion requires the presence of an anode that gives up electrons, a cathode that accepts electrons, and an electrolyte that facilitates the flow of electrons between them.
In the formation of iron oxide, iron is the anode. As a metal, iron usually permits the flow of electrons through it with little resistance. Paradoxically, this also makes iron an ideal cathode as electrons flow from one section of the metal to another through the electrolyte.
The electrolyte that drives the oxidation is usually water. A drop of rain picks up carbon from the atmosphere as it falls, thereby transforming into weak carbonic acid. This acid in contact with the anode surface strips electrons from the iron surface and transmits them to the cathode. The energy this process imparts to the electrolyte breaks the bonds between hydrogen and oxygen in the water.
The oxygen atoms displaced by the electrical flow through the electrolyte are taken up by the water and bond with the free oxygen. The molecules of iron oxide are much larger than those of the pure iron that formed it, so the thin oxide layer that forms on the iron surface sloughs off easily. This exposes a fresh surface to the carbonic acid and allows the process to continue.