Flowering plants produce volatile chemicals in flowers which evaporate into the air and produce their fragrances (pleasant or sometimes unpleasant — at least to humans). Presumably, these specific flower fragrances attract pollinating insects, but this is not necessarily so, since we don’t know whether insects "smell" the same way humans do.
But indeed, gardening is a rewarding experience. Not for one reason, but for numerous reasons. One of the most apparent rewards is a beautiful display of flowers. Flowers have evolved into specialized pollination machines. Some cross-pollinated plants are anemopholous, or wind-pollinated. These plants tend to have inconspicuous flowers and produce a lot of pollen, because wind currents cannot selectively identify which plants are receptive to specific pollen. On the other hand, flowers pollinated by insects (entomophilous flowers) often advertise themselves. One way to advertise is by colors. Another interesting way to advertise is by flower fragrances.
The underlying biological purpose of flower fragrances is to advertise to insects that food (nectar or pollen) is available, or to fool the insects into a hungry or amorous condition. The insect visits the flower, looking for food or a mate. If all goes well for the flower, the insect will take some pollen with it before it leaves, then serendipitously deposit that pollen on the stigma of another flower of the same species, thereby cross-pollinating the plants.
It is likely that flower fragrances evolve from chemicals originally meant to deter herbivores. Insects that visited these flowers, looking for pollen or prey to eat, were able to sense these chemicals. If the chemicals were not irritating or deterring to the insects, they would selectively visit flowers with these fragrances, which identified them as having available food. Another evolutionary scenario could be that insects that were able to successfully find a mate on a flower with a certain fragrance would return to a flower with that fragrance, looking for a mate.
The chemicals that we sense as fragrances are widely varied. The distinctive fragrance of jasmine (methyl jasmonate) comes from the metabolism of cell membrane components. Simpler forms of cell membrane derivatives, like short-chain ketones, aldehydes, and alcohols, give flowers distinctive fragrances. Other volatile compounds, like methyl salicylate are benzoic acids, structurally related to acetylsalycilic acid, or asprin. The fragrant phenylpropanoids are related to the fragrant compounds of cinnamon and nutmeg. A large number of flower fragrances are simpler forms of the terpene resins that seep from pine trees. Specific flower species tend to have specific flower fragrances as a result of combination of these chemicals in varying proportions.
Specific flower fragrances attract specific insect pollinators. For example, the titan arum and carrion flower attract beetles and flies that feed on or lay eggs in rotting flesh. As you may suspect, the flowers stink like rotting flesh. Different but specific fragrances also help to ensure that insects visit flowers of a similar species, increasing the potential for successful cross-pollination. Flower fragrances may serve to make it easier for insects to find the visual cues of the flowers, and fragrances probably evolved before visual flower signals. From a long distance, flower fragrances are more effective than visual signals in attracting a pollinator, especially to small or hidden flowers.
Flower fragrances tend to be at their highs when they have sufficient nutrition. In addition, moderate to warm temperatures and high light tend to increase fragrances, but higher flower fragrances also reduce their life-span. If the flower uses energy to make fragrance, it can’t use that energy to keep itself looking nice. In breeding programs for cut flowers, like roses, vase life is an important characteristic to select for.
Production of many flower fragrances displays a circadian cycle -that is, they are stronger at certain times during the day or night. Snapdragons, for example, are more fragrant during the day, when bee pollinators are likely to be active. Nicotiana is more fragrant at night, when its moth pollinators are out and about.
The location of fragrance production on the flower varies. Some flowers have fragrant pollen. The oily coat of the pollen may contain its own profile of fragrant compounds that is distinct from the fragrance profile of the rest of the flower. Different parts of the petal or pistil also often make fragrant compounds, and often in different quantities. Rose pollen, for instance, contains a fragrance profile separate from the rest of the flower, but fragrances from the rest of the flower usually overpower pollen fragrances.
As you may have noticed in your travels around the garden after a rain, flower fragrances are often stronger when the air is humid. This is because the scent molecules are able to travel farther and are easier for your nose to pick up when the air is more humid. The flowers may also release more fragrant compounds under humid conditions.
Learn More about Fragrances of Some Specific Flowers