In 1871, James Clerk Maxwell proposed a thought experiment:
Since temperature in an enclosure is related
to the average kinetic energy of the particles
contained in it ...
... this will result in the creation of a temperature
gradient between the two compartments.
Java applet by Albert
Smith
Try to separate the fast (red) and slow (blue)
molecules to make one side of the room warmer than the other.
Click to open/close the green door
We end up with a hot, high pressure gas on one side, and a cold, low pressure gas on the other.
Conservation of energy is not violated ...
... but
we've redistributed the random kinetic energy of the molecules (heat) in
such a way that energy can now be extracted from the system (e.g., to drive
a gas turbine).
So, the demon has managed to decrease the entropy of the system.
But, thermodynamics says this is impossible.
This problem has led to very interesting links between physics, information theory and the theory of computation - from concepts of information entropy (Brillouin, Szilard, Shannon) to reversible computing (Landauer, Bennett).
Also, a real demon will have to acquire information about the world through physical interaction with it - on the atomic and molecular scale we cannot ignore the quantum mechanical nature of the world.
For example, to be able to see the molecules, the demon will have to absorb whole photons at a time, and any detailed version of the thought experiment will run into the uncertainty principle and the fact that an interacting demon will acquire the same temperature as the rest of the system.
This has led to interesting ideas in quantum information theory, quantum computing and macroscopic decoherence of wave functions (Zurek, Bennett).
But let us see what the venerable Richard Feynman
has to say about it.