Terpenes are the aromatic oils that give cannabis distinctive flavors like citrus, berry, and mint. They are from the same glands that produce the cannbinoids THC and CBD. Similar to other plants and flowers, these scents were originally seen to repel predators and lure in pollinators. There are also several factors that influence the production of terpenes, such as climate, fertilizers, and soil types.
There are over 100 identified terpenes and every strain has a unique composition. They relate to the different effects of the various strains, but more research has to be done to understand this as well as how each terpene interacts with others, known as the entourage effect. Some cannabis terpenes are more common than others and these are explored in detail below.
(Sources: What are cannabis terpenes and what do they do?, What Are Terpenes?)