Cooling of the hot wort is a critical step for several reasons.
Yeast are killed by high temperature.
Wort produces dimethyl sulfide (DMS) at high temperatures, and between the point where the temperature is just not high enough to boil it off and that where its rate of formation is negligible (i.e. room temperature) this flavour accumulates.
Some spoilage bacteria can grow in the wart as it cools (e.g. if the wort is contaminated after boiling, by air or by condensate), and the longer that these have to grow before the yeast is pitched, the greater effect that they will have on the beer.
Oxygen reacts with hot wort to produce undesirable flavours. (Note however, that once the wort is cooled, it is much less reactive, and in fact it is essential for oxygen to be added to wort, as yeast cannot synthesise certain lipids required for their cell membranes without it).
In a home context, beer is usually cooled in one of two ways:
By immersing the metal boiling vessel, for example in a laundry basin full of water
By inserting a cooler or cooling coil into the wort.
Using a counter current heat exchange (usually a copper pipe immersed in a wider diameter plastic pipe with the wort and the beer flowing in opposite directions).The laundry basin method has the advantage of being cheap, and requiring no additional equipment. The cooling coil is however far quicker. A simple heating coil can be made from copper pipe, (such as the type used in domestic houses). The pipe can be bent with a pipe bender, obtained from an ordinary hardware store, and once it is coiled, two polyethylene tubes can be attached to it. The whole apparatus is then submerged into the wort boiler, and one polyethylene tube is connected to a cold water source, and the other outlet pipe is drained away. The pipe should be "painted" with a thin layer of epoxy to prevent copper leaching off it - alternatively, if you can get it, stainless steel pipe may be used.