According to the BBC, potatoes produce electricity by virtue of their acidic juice, which reacts with two electrodes placed in the potato. The chemical reaction produces a weak current between the two electrodes.
The negative electrode, which is called the anode, is usually made from zinc, while the positive electrode, which is called the cathode, is usually made from copper. This electrical phenomenon was first discovered by Luigi Galvani in 1780, who was experimenting on frogs with electrodes. This same phenomenon works with a variety of other organic materials, including dirt, paper soaked in saltwater, and other fruits and vegetables, such as lemons.