Distillation can be used to separate two liquids that are fully mixed together to form a solution.
When two liquids can fully mix together they are called miscible liquids. Liquids that do not mix and form layers are known as immiscible liquids.
Distillation only works with liquids that have very different boiling points. A good example is ethanol and water. Both are clear colourless liquids that look almost the same. However, ethanol boils at 78°C and water boils at 100°C. So when the mixture reaches 78°C the ethanol boils and travels to the boiling tube as a gas. It then condenses as highly concentrated ethanol (not pure ethanol, as some of the water in the mixture would still evaporate) and is collected (the liquid collected as the end of the distillation is known as the distillate). The liquid left behind in the conical flask will then be mostly water. To obtain pure water, you would have to change the receiving flask when the temperature on the thermometer reached 100°C.