From science class in 7th grade, we remember that when a gas is compressed (or pressurized), its temperature increases. 7th grade also told us that higher temperatures mean gases will be less dense, or contain less mass per unit of volume. We want as much mass of oxygen in the combustion chamber as possible, so we want the intake charge to be cool. The intercooler does this for us. It works like a radiator, by first transferring the intake’s thermal energy to itself, and then transferring it to the ambient air (or water in some cases).
There are some caveats to this, though. Many people tend to think the bigger intercooler the better, and in some ways this is true. By having more surface area, a larger intercooler is able to exchange more heat with ambient air. However, an intercooler that is too large will have more volume, which means the compressor will have to pressurize a larger volume of air (imagine inflating a small party balloon, and then inflating a hot air balloon to the same pressure).