* Water (H₂O) is a polar molecule. This means it has a slightly positive end and a slightly negative end due to uneven sharing of electrons. This allows water molecules to form strong hydrogen bonds with each other.
* Oil is made up of nonpolar molecules, like hydrocarbons. These molecules have an even distribution of electrons and don't have the same strong attractions that water molecules do.
Because of this difference in polarity, water molecules are attracted to other water molecules, while oil molecules are attracted to other oil molecules. This means they will separate into distinct layers, with the less dense oil floating on top of the water.
There is no chemical reaction happening, just a physical separation based on their different molecular properties.