The particles in a gas move randomly and each one has kinetic energy. The temperature of the gas depends on the average kinetic energy of its particles, and the total energy stored by all the particles is its internal energy. Anything that gives the particles more kinetic energy raises the temperature.
Doing work on a gas transfers energy to it. When a piston is pushed into a gas, the particles bounce off the moving piston. A particle hitting a piston that is moving towards it rebounds faster than it arrived, just as a ball hit by a moving bat leaves faster. So the particles gain kinetic energy, the internal energy of the gas increases and its temperature rises.
A bicycle pump shows this clearly. When you push the handle in quickly, your hand does work on the air trapped in the barrel. The air is compressed and becomes hotter than before, and the barrel feels warm near the outlet. If you stop pumping, the air slowly transfers energy to the surroundings by heating and cools back down. Pumping fast makes the effect bigger because there is less time for energy to escape to the surroundings.
The reverse also happens. When a gas expands and pushes a piston outwards, the gas does work on the piston, so its internal energy decreases and its temperature falls.