Barrels have been used since early Roman times as their cylindrical shape enables them to be rolled, but the bulge in the middle makes it easy to change direction whilst rolling. They could also be floated behind a boat, not taking up valuble space onboard. Fish and sauerkraut were salted and preserved in barrels that could be buried underground to keep them cool.
Oak was traditionally used for wine barrels. The oak was left to age in the air, releasing volatile compounds that might ruin the wine. The wood was then cut to the correct lengths and assembled into a barrel shape by the cooper. The wood would be steamed to make it flexible and hot iron hoops were fitted to the outside to hold the wood in the correct shape. As the iron cooled and contracted, it would provide a tight seal by forcing the slats together. Lids and bases could be made to fit in a similar way. Cheaper barrels might be painted in tar to help keep the air out and seal any tiny leaks.
There is a superb video on making a barrel here by Jim Beam: http://www.youtube.com/watch?v=kImm3teJ3c0
Barrels lasted for several journeys and sometimes carried different goods, the previous cargo leaving taints in the container. Whisky is often stored in oak barrels that sherry has previously been stored in to give it a more interesting flavour as the sherry compounds leach out of the wood. Oak aged beer is usually stored for months in a barrel to absorb some of the tannins from the oak to give a subtly oaky flavour to the beer. Sometimes the wood is shredded into chips and dunked directly into the fermenter or maturation vessel to impart a flavour.
For beer storage and transport, barrels come in several standard sizes;
Pin - 4.5 gallons
Firkin - 9 gallons
Kilderkin - 18 gallons
Barrel - 36 gallons
Hogshead - 54 gallons
Butt - 108 gallons
Beer barrels are now almost all made of stainless steel and the few coopers left are in the whisky or wine industry where the price of the contents of the barrel are many times higher and the customer is prepared to pay for the aging process.