When a gas expands, it has do pressure-volume work against the piston, atmosphere etc. to make its room to occupy. Now, as the system spends energy to work, part of its kinetic energy decreases. Since, temperature is directly proportional to kinetic energy, the system's temperature decreases.
An example:
Much of chemistry takes place in vessels that are open to the atmosphere, and subjected to constant pressure, not constant volume in a rigid,sealed container. In general,when a change takes place in a system open to the atmosphere, its volume changes. For example, the thermal decomposition of of $1.0 \text{mol} \mathbf{CaC{0_3}}$ at $1 \text{bar}$ results in an increase in volume of nearly $90~\text{dm^3}$ at $800^\circ ~\text{C}$ on account of the carbon dioxide gas produced. To create this large volume for the carbondioxide to occupy, the surrounding atmosphere must be pushed back. That is, the system must perform expansion work. Therefore, although a certain quantity of heat may be supplied to bring about the endothermic decomposition, the increase in internal energy of the system is not equal to the energy supplied as heat because some energy has been used to do work of expansion. In other words, because the volume has increased, some of the heat supplied to the system has leaked back into the surroundings as work.
source: Elements of Physical Chemistry by Peter Atkins, Julio De Paula.