Because you are doing work to compress the gas, and the energy has to go somewhere. The molecules speed up because they collide with the wall moving forward--- if you move a wall forward, a ball which bounces off the wall reflects going faster by twice the speed of the wall, because if you move along with the wall, it reflects at the same speed.
Answers to comment questions
- After the gas cools off, the gas molecules are moving at the same speed as before.
- The second question is a form of Maxwell demon. If you know when the molecular collisions come with such precision that you can move the wall when the molecules will not bounce, you can compress the gas without doing any work. But in order to do this, you must get and store the information about where all the molecules are, a process which requires a huge amount of entropy production. The information about the molecules allows you to reduce their volume without increasing their energy.
- In any situation where classical mechanics works, for kinetic energy of gasses in particular, the temperature is just the same as the average molecular kinetic energy. For all nonrelativistic systems, the average kinetic energy in each atom is $3T\over 2$ in Boltzmann units (k=1). This is a special case of the equipartition law--- every quadratic degree of freedom gets ${kT\over 2}$ energy in equilibrium. Because of the relation between temperature and kinetic energy, the speeds of molecules in two gasses at the same temperature are the same. So after the gas comes to equilibrium with the surroundings, it has the same average speed for the molecules independent of its volume (this is a molecular kinetic-energy potential-energy separation theorem, which is even true when the material liquifies or solidifies, at least at room temperature where normal solids obey the Dulong Petit law).
Entropy increase
There is a second way to understand the temperature increase. When you squeeze the gas, you are increasing your knowledge of where the molecules are, you are decreasing their wandering volume. This means that, if nothing else happens, you decrease their entropy. So something must have happened to make you know less about the state of the universe. If they are not allowed to dump heat and entropy into the exterior universe, the only thing that can happen is that they move faster, increasing your uncertainty about how fast they are going.
The decrease in entropy with a decrease in volume from $V_i$ to $V_f$ is
$$ N\log({V_f\over V_i}) $$
This is intuitive--- the logarithm of the number of configuration is the log of $V^N$ (ignoring an N! denominator from indistinguishable particles.
The increase in entropy from a change in temperature from $T_i$ to $T_f$ is given by
$$ NC_V \log({T_f\over T_i}) $$
Where $C_v$ is the rate of entropy increase per unit temperature. So that the relation that the entropy is constant gives the adiabatic expansion law: $V\over T^{C_v}$ is constant, that is, the ratio of absolute temperatures before and after is a certain power of the ratio of the volumes after and before.
This is a classical more-you-know less-you-know statement, that the more precisely you know where the molecules in a gas are, the less precisely you know how fast they are moving (the hotter the gas gets), at constant information (entropy). This is not the Heisenberg uncertainty principle, it is just classical thermodyanamics, and here the knowledge interpretation is exact, because the entropy is a measure of classical knowledge you have about the microstate. The quantum mechanical uncertainty principle is not a statement of ignorance about hidden variables, at least not in any obvious way, so it doesn't have a precise informational interpretation like this does.