Sunlight is needed for the photolysis of water during photosynthesis.
It is called Hill Reaction in which as the name suggests water is split into hydrogen and oxygen in the presence of light. The reaction generates electrons, hydrogen ions (protons) and diatomic oxygen gas.
As a result of light reactions energy rich compounds like ATP and NADPH are produced.
These compounds are used byt he plant in the dark reactions of photosynthesis to produce sugars.

