The metabolism of living organisms as they evolved on earth constantly dissipates energy in a non-reusable form. To sustain life this energy has to be replenished. The only external energy source is the sun, so life has to cope with utilizing light to fuel all metabolic demands.
Photons emanated by the sun carry energy depending on the colour of the light.
So all we need is a machinery to catch the photon's energy and store it in the form of say a phosphoester bond. Nature accomplishes this task with the aid of multienzyme complexes organized in cellular membranes. The simplest systems are found in purple photosynthetic bacteria. Turning the quinone cycle expels protons from the cytoplasm to the periplasm. The electrochemical gradient thus generated is used to drive ATP synthesis by the membrane bound F 0 F 1 -ATPase.