We'll use just the most basic type of battery used for a car, the battery in your car or motorcycle may be different but the basic principles will be the same for all lead-acid batteries.

What it does.
A battery is an essential part of a vehicles electrical system as a storage medium mainly for supplying the high current for starting the engine of the vehicle but also for supplying a voltage to electrical systems when the engine is not running. Items such as parking lights or the radio or any of the auxiliary features that a car or other vehicle might have.

when the engine is running the battery normally gets it's power from the alternator which supplies an alternating current or a dynamo which supplies direct current. Most modern cars will be using an alternator. The battery is still used to supply the power to the same auxiliary functions but is being constantly recharged by the alternator.

Lead - Acid
Most standard car batteries are what are known as lead-acid which of course means that the main components are lead and acid(sulphuric acid diluted with distilled water). These 2 components are reacting together to take in or release a charge of electricity.

Construction
There are normally 6 cells in a car battery each giving around 2 volts which makes a total of around 12 volts. The lead plates, 2 or possibly more in each cell (depending on the current required), are the electrodes, positive and negative and the acid is the electrolyte). The lead plates will have in the negative plates 'spongy lead' and in the positive plates there will be lead dioxide. The individual cells are connected in series to give the required 12 volts.

Charging
when you charge this type of battery hydrogen is released from the negative electrode and oxygen is released from the positive electrode, when this happens a chemical change starts and the lead oxide paste in the negative electrodes change to spongy lead while the lead oxide paste in the positive electrodes change to lead peroxide. Lead sulphate from the plates combines with the electrolyte to increase it's specific gravity.

Discharging
While the battery is discharging the opposite is happening, so hydrogen is being formed at the positive plates and oxygen is being formed at the negative plates. Also the lead sulphate now recombines with the active material in the lead plates. This has a detrimental effect on the electrolyte which becomes weaker and the specific gravity is reduced. Also if a battery is allowed to remain in a discharged condition too long the lead sulphate may form into crystals which then can't continue with the chemical changes needed for a good battery condition. This is known as sulphation. Light sulphation can be removed with a good battery conditioner however heavy sulphation can be difficult to remove and could result in a useless battery. So it is a good idea to keep a battery maintained in good condition with some form of trickle charger or preferably an intelligent battery conditioner.

Maintaining a battery
a lot of car/vehicle batteries nowadays are maintenance free but even if it is there are still some things that need to e checked regularly, the battery top should be kept clean and free of any debri and the area should be kept dry. The connectors should be coated with petroleum jelly or some specialist battery grease which are normally anti corrosive and expel water. Normal grease should never be used as this can sometimes soften the battery top sealing materials. Any corrosion around the battery area should be treated and repaired and the source of the corrosion must be found and remedied. Corrosion can sometimes be caused by the battery having too much electrolyte in it and spilling out. If the corrosion is due to the battery fluid then this can be cleaned with a solution of washing soda or diluted ammonia. If the battery is not maintenance free then the electrolyte should be checked at regular intervals. The electrolyte should be just above the plates, usually there are tabs in the holes which can be used as a gauge for the fluid level. For good maintenance this check should be done probably once a month or maybe every thousand miles. This is necessary because as the battery cycles through it's various conditions it will be producing heat, this can over time cause the electrolyte(the water in it) to evaporate. If a top up is required then only distilled water should be used, normal water will have impurities which over time will build up and could weaken the battery until it gets into such a condition that it can't perform its cycles. A benefit of keeping a battery in good condition especially in the winter is that when a battery is fully charged the electrolyte can't freeze.