Plants called angiosperms produce flowers, and they create them as a way to reproduce. Indeed, flowers are the sexual organs of angiosperms, and some are male, some are female and some are hermaphroditic, possessing both male and female parts. These parts make flowers a rather specialized feature of angiosperms, and they perform functions that enable the plants to perpetuate themselves.
Sperm & Ovules
For reproduction, angiosperm plants need to create sperm, so the plants create male and hermaphroditic flowers to produce it. The flowers grow stamens, each stamen composed of a filament that has an anther on top, which is often lobed. The anthers produce pollen. Contained within that pollen is sperm. When sperm meets egg, fertilization occurs in the flower, the basis for seeds, fruit and future plants.
Flowers are also necessary for a plant to produce eggs with which the sperm can fuse. These are held in a flower structure called a pistil, found in the center of female and hermaphroditic flowers. The bulbous base of the pistil is the ovary, which contains the eggs.
Producing sperm and egg wouldn't do a plant much good if the sperm couldn't actually get to the eggs so fertilization can take place. Some flowers primarily use the wind to spread pollen from flower to flower. Other plants, though, need help. To lure insects, mammals or birds over, the plants create big, showy flowers with scent and nectar. Creatures visit, picking up pollen as they do so, and when they visit another attractive flower, they drop off the pollen so fertilization can take place.
Some plants prefer certain kinds of pollinators over others and grow flowers to particularly appeal to their favored helpers. For instance, flowers that have a tubular aspect are likely trying to attract hummingbirds with their long beaks or butterflies with their long tongues.
Colors also attract certain kinds of pollinators, as does scent. There are even flowers that smell like rotting corpses to attract flies. Sometimes they even produce parts that look like rotting flesh.
Angiosperm plants must produce flowers in order to create seeds, which are formed from fertilized eggs. Fruits are also formed as a flower's ovary ripens and swells. In some fruits, the ovary is visible as the walls of the fruit. This is the case, for instance, in pea pods. In other fruits, other flower parts are easy to pick out. A pomegranate has a tubular prominence at one end that is the remnants of the flower's calyx, a term referring to a flower's sepals as a group. Sepals are located at the bottom of a flower.