Black-eyed Susan (the black in the middle is the seeds)
The earliest flowers probably developed about 130 million years ago, in the Cretaceous period, as a way to attract newly evolved flying insects - mainly bees - and get them to help spread the plant's pollen far away from where the plant was growing, to make new plants. Bees and flowers seem to have evolved together; neither could live without the other.
Like earlier gymnosperms, flowering plants start with tiny seeds at the end of branch stems, in a swelled out part we call the ovule or ovary. The seeds rise up along a tube called the pistil and come out the end.
Daffodil with petals and pistil in the middle.
All around the sides of the ovary and pistil are the stamens, which evolved out of leaves. The stamens make pollen. When the pollen gets on the seeds, the seeds are fertilized and can produce a new flower. Some flowers, like wheat and other grasses, let their own pollen fertilize their own seeds, but more often flowers evolve so that bees carry their pollen to other flowers to increase genetic diversity. That makes for stronger, healthier flowers.
The first flowers relied on wind to move the pollen, and then on bees just happening to come by at the right time, but gradually some flowers evolved to encourage the bees to fly from flower to flower. These flowers evolved to make bee food - nectar. Flowers make nectar, which is basically sugar water, down at the bottom of the ovary, at the base of the petals. Some plants even may make drugs like caffeine or nicotine or opium in their nectar to get the bees to come. When bees fly down into the flower to get the nectar, they get pollen all over themselves, and then when they go to another flower to get more nectar, they rub the pollen off over there.
To let the bees know where to go, flowers also evolved bright, showy petals and strong smells. Petals, like stamens, evolved out of leaves. Some plants have simple petals that are just leaves without chloroplasts in them, so that they are red or yellow instead of green. Other plants have much fancier petals.
To find out more about flowers, check out these books from Amazon.com or from your library: