In 1867, James Clerk Maxwell proposed an image that still stirs physicists today. Two compartments of gas are separated by a door. Molecules dart about chaotically: fast and slow. A tiny gatekeeper opens the door only for fast ones, letting them through to one side, and slow ones to the other. The hot compartment gets hotter, the cold one colder. Work without cost — a perpetual motion machine. Thus Maxwell showed that the second law of thermodynamics is not an absolute law but a statistical inevitability.
The demon seemed to have found a loophole. But each step of its work came at a price. In 1929, Leo Szilard simplified the problem to a single molecule and realized that the very act of measuring the particle's position already produces entropy (a measure of disorder)—at least as much as disappears during sorting. Later, Leon Brillouin showed that to 'see' the molecule, the demon needs light, and the photon pushes the particle, blurring the picture. The decisive blow came from Charles Bennett in the 1980s: even if the measurement went perfectly, the demon must erase old records in its memory, and erasing one bit irreversibly releases heat.
Quantum nature imposes an even stricter barrier. The uncertainty principle of Werner Heisenberg forbids knowing both the position and velocity of a particle precisely at the same time. The demon cannot measure a molecule without affecting it: every act of observation inevitably changes its motion. This is like trying to catch a butterfly with tweezers — the very touch alters its trajectory. Thus the quantum world protects the second law more reliably than any lock.
The term 'demon' was coined not by Maxwell but by William Thomson (Lord Kelvin), and he was also the first to use the word 'demon' in a scientific context — before that, Maxwell simply called it a 'being'.
In Stanisław Lem's novel 'Peace on Earth', Maxwell's demon becomes a weapon, and in the story 'The Fourteenth Voyage', Ijon Tichy encounters a civilization that tried to harness demons for a perpetual motion machine.