The famous Joule-Thompson experiment was designed to answer an important scientific question of the day: Do gases cool down as they expand? The two scientists found that in a situation where no overall work is being done, all real gases except hydrogen and helium cool down.
To discover this principle, two scientists, James Prescott Joule and William Thompson, set up an experiment in which they created a closed system and forced gas from one container to another. The scientists measured the pressure, volume and temperature of a gas and then forced it through a porous plug at a constant pressure. Forcing the gas from one chamber to another changed the pressure, volume and temperature of the gas.
The reason for this is that when the gas passes from one container to another, the molecules must stretch farther apart and the bonds between them have to weaken. This takes work, and the work that is being done lowers the overall temperature of the gas.
The two gases that are exceptions to this rule are hydrogen and helium, because the bonds between the atoms in these gases are very weak. They only cool if the experiment is performed at very low temperatures.