This is only true for real gases (not ideal gases). Real gases have intermolecular attractive forces that have to be overcome as the gas expands (as the molecules spread out from each other) and this requires energy. Therefore real gases lose energy as they expand and this is reflected in a decrease in the temperature.