A typical battery, or dry cell, consists of a graphite anode and a zinc cathode, separated by a thick paste of chemicals which react with the graphite and zinc in an oxidation/reduction reaction to produce electricity.
As energy is taken from the battery the by-products of the chemical reaction accumulate around the electrodes, reducing the area of the electrodes in contact with the unreacted chemicals in the paste, which leads to a drop in the voltage produced by the battery.
If a dead battery is left unused for a short period of time, some of the by-products will move away from the surface of the electrodes due to diffusion, and the battery will appear to have regained some of its power. Warming the battery gently (eg. near a radiator) will speed up the process of diffusion.