You eat a photosynthesising prokaryote. You think it is tasty food. Luckily, over time, you have been letting lifeforms like it live on inside you for a little while, because they can continue photosynthesising and making sugar while inside.
In fact, you have evolved to provide the chemicals it needs as food to extend its life inside you.
This adaptation has now reached the point where you can contain multiple photosynthesing bacteria, and they can live on inside you indefinitely.
You have entered a symbiotic relationship, and they will never live outside again, getting food and protection, for the price of a few sugars. You are, together, a single organism, of which it is just one part: a chloroplast.
Inside the host, it photosynthesises using a chemical called ‘Chlorophyll A’, which turns you both a blue-green colour and gives you a supply of sugars all the time you are in sunlight. Chlorophyl A doesn’t absorb all the sunlight though - only a part - the rest is wasted.
The usual copy-error effect can give you the ability to make a slightly different version of chlorophyll which will work using a different part of the sunlight spectrum, but it means you’ll make less of Chlorophyll A. Interested?