Subtle flavors are imparted to wine as it ages in the barrel. Different types of oak (French and American being the two most widely used) from different regions (Limousin, Nevers, Troncais, etc.) give differing levels of flavor to the wine (most often described as vanilla).
Wine, as it rests in the barrel, goes through subtle chemical changes, resulting in greater complexity and a softening of the harsh tannins and flavors present at the end of fermentation. The effect of specific wood on different wines is the subject of great discussion and experimentation among wine makers throughout the world.
A barrel essentially does two things: it allows a slow introduction of oxygen into the wine; and it imparts the character of the wood into the wine. (This diminishes as a barrel gets older. You usually get 50% of the extract that a barrel has on the first use, 25% the second and less after that.)