A battery works because of corrosion.
On the surface of all metals are loosely bound electrons. When two metals are placed in contact, the atoms of each compete to attract the electrons. The more “noble” metal (the cathode) attracts electrons from the more “active” metal (anode). The movement of electrons causes the anode to corrode, and produces an electric current. A common household battery generates current with a carbon-zinc cell, in which the zinc corrodes preferentially to the carbon (often considered a “metalloid,” which behaves similarly to a metal).