The answer is: to absorb energy from the Sun.
Pigment chlorophyll is inside the organelle called chloroplasts. When Sunlight enters the leaves and reach chlorophyll, light excite it and a series of chemical reactions begin. Those reactions are the part of photosynthesis. As the result of chlorophyll excitement by light, carbon dioxide and water are converted into glucose and oxygen using the energy from the Sun.