That's an easy Google search man.
http://www.google.com/search?q=how+d...tercooler+work
In short, a turbo compresses air. When you compress air, it gets hot. When air gets hot, it expands. Since expansion means that the engine gets less air than it could. An air-to-air or liquid-to-air intercooler, a big heat exchanger (aka radiator), is used to cool the air temp. You run the hot compressed air from the turbocharger through the intercooler to bring down its temperature and make it more dense.
There's a lot more detailed information via that link I provided.
This is probably the most detailed explination -
http://www.gnttype.org/techarea/turbo/intercooler.html
As far as making one from scratch. Just buy one. There are plenty of kits available for the 3sgte and if you boost the 5s you'll need to get a universal FMIC fit and mounted plus the pipe custom fit, cut and joined.