In a galvanic (or voltaic) cell, a redox reaction occurs spontaneously. The chemical energy released during the redox reaction is converted into electrical energy that flows through an external circuit.
This is the basic working principle of batteries.