It is because gas molecules have less energy per unit of volume than solid or liquid molecules. The energy of a molecule is proportional to its temperature and pressure, so if the temperature stays constant, a gas will expand if it is compressed.
For example, consider two particles A and B that are at different temperatures. Particle A has more energy than particle B and therefore will be moving faster than particle B. If we put both particles into the same container and allow them to move around freely, they will collide with each other frequently because they have different energies. This causes the average kinetic energy of these two particles to decrease as time goes on because their motion has been slowed down by their collisions with each other.
When this happens, their kinetic energy is shared between them in some way (usually by transferring some kinetic energy from one particle to another). This means that both particles have lower average kinetic energies than they did before they collided with each other.
Last modified: September 19, 2022