The first cells that could make sugars out of sunlight and carbon dioxide and water by photosynthesis probably evolved around 3.8 billion years ago. They were prokaryotic cells that looked blue-green, because they needed to absorb all the warmer wavelengths of light and reflect the cooler blue and green ones.
But when other cells ate the blue-green prokaryotes, they found out that it was more useful to let the blue-green prokaryotes live inside them and keep making energy from sunlight, than it was to destroy them. Gradually more and more cells began to have lots of blue-green prokaryotes living inside them, and by around two billion years ago some of the blue-green prokaryotes lost the ability to live on their own and evolved into chloroplasts (KLOR-oh-plasts) that could only live inside other cells (This is very much like what happened to mitochondria).
A video about chloroplasts
Learn by doing – chloroplasts
A project to use chromatography to see the colors in leaves