Liquids will separate from each other if their density is different. Less dense liquids will float on top of more dense liquids. Oil is less dense than water, hence it floats to the top.
If you shake up a bottle of salad dressing (oil and vinegar) it will mix for a short period before separating into two layers.
A separating funnel, as illustrated, is an easy method used to separate liquids of different density.
The tap at the bottom of the container allows the liquid at the bottom, in this case coloured water, to be separated from the oil on top.