The process of distilling water, crude oil or ethyl alcohol are all based on similar science.  When two or more chemicals are thoroughly mixed in a liquid, being able to separate them can be quite a challenge. 

In many cases, an economical solution is to use a distillation process.  The science behind this is very interesting and worth some attention.

When you have a liquid, the density of this material is typically very similar to that when it is frozen solid.  The biggest difference is generally that the molecules and atoms in the liquid are randomly distributed but in solids, the atoms tend to line up in a periodic fashion if not being a full crystal itself. 

The reason the molecules in the liquid are randomly arranged is because of heat.  When you heat a solid to its melting point, you add enough energy per atom to start breaking the bonds which were holding the atoms together.  This usually only prevents the atoms from staying stuck to individual nearest neighbor atoms as they still are attracted to each other, they just have so much heat that they can't stay stuck in a single location.

The addition of heat to a solid comes in the form of vibration motion to the atoms.  If you keep adding more and more heat, the atoms vibrate faster and faster.  Eventually they vibrate so hard that they break the bonds keeping them fastened to their nearest neighbors and the material melts.  Once melted, the atoms are still attracted to each other but they are moving so fast, they are in a situation where they are both bouncing off each other and being strongly attracted at the same time.

Pouring more energy into the material will continually make the atoms move faster and faster.  Eventually the liquid molecules will be moving so fast that the attraction between them becomes small compared to the pushing they give to each other from their smashing around (like pool balls on a pool table).  When this happens, the material boils and starts converting its atoms from a liquid into a gas.

The energy individual molecules and atoms have at a given temperature are not all the same value.  The speed any particular atom is traveling can vary from zero (being completely still) all the way up to some extremely high values.  The average speed of a given atom is the value which determines the material temperature.  It is the average speed or energy of all the atoms and molecules that determines its pressure and temperature even though some atoms will have much lower and much higher values than this average. 

Like the pool balls on a pool table after the break, some balls will be moving fast, some will not move at all and there will be an average speed for the lot of them somewhere between these extremes.  This analogy works for the atoms in a material except it is the average speed of the atoms which determine temperature.

When you have a liquid surface touching a gas such as the surface of a body of water, those molecules in the water that were at the highest range of speeds can literally jump out of the water and become vapor (if they were going in the right direction close enough to the surface).  Similarly, water vapor in the air above the water can impinge on the surface of the water and become part of the liquid.  So we have some water evaporating into the air and some of the water in the air able to condense into the liquid of the pool.

If the system were closed (like an indoor swimming pool), then eventually this process would go into equilibrium (staying the same) where you have just as much water evaporating from the pool as you have water vapor (humidity) condensing into the liquid of the pool.  This equilibrium balance is very sensitive to temperature so that if you increase the temperature, you increase the amount of liquid that goes into the vapor phase of the air above it.

If you have a mixed liquid (such as salt in water), those molecules having the lowest binding energy to the liquid will evaporate first.  With salt water, the salt is attracted to the water and other salt far stronger than the water molecules are attracted to each other.  This is why the water evaporates first and leaves behind the salt as a crystalline crust after all the water has evaporated or been boiled off.  By collecting the water on a separate condenser, the water has now gone through a process known as distillation.  

The same process can occur for mixed organic molecules where you generally get less complete separation with a single boiling cycle.  Generally you simply concentrate one type of molecule more than the other from a single boil and then condense the vapor in a separate location and repeat the process.  With each repetition, you will be increasing (or decreasing) the material of interest until you reach the desired purity for your application.  

This process is used for separating out the various constituents from crude oil to give us such things as gasoline, kerosene, jet fuel and deisel fuel.  Hopefully you now have a better appreciation for distillation.

Top image: Andreas Levers