I know this sounds like an odd thing to ask, but I've found that there's a reason for just about everything in nature.
Do the plants put out an odor to attract insects for pollination reasons? Or? Or? Discuss
It occurs to me that the skunk odor may have been naturally selected cuz it repels animals. I'd never intentionally eat or smoke anything that smelled like skunk, unless i knew what i know about weed.
Perhaps to make it easier for humans to find it, also for resistance to pests. Do insects actually pollinate cannabis? I know birds love the seeds. I don't know what other animals are attracted to the plant.
It makes sense to me that like most things in nature that are bright colored, aromatic, toxic, or intoxicating; it is a defense mechanism.
Cannabis has many uses to "us", humans like, oils, hemp, seeds, fuel, smoke and hash, but in nature a cannabis plants entire purpose and reason for existing is to produce seeds and protect them until matured.
The resin that we like so much, serves the same purpose as skunk spray.
Many plants and flowers do indeed release aroma that is apparently either an attractant or a repellent. Scientists can show that the plants either attract or deter specific insects and animals. In some cases a plant will release it's aroma only when things are right for it to attract certain moths, such as a plant that only releases aroma at night to attract a specific nocturnal moth.
But the aroma of plants and flowers is not always the case of it producing an attractant or deterrent, but rather a consequence of it's biological make-up. Many plants produce terpenes. Terpenes are natural oils within many plants and flowers.
Cannabis produces essential oil terpenes, which are known to produce resins.
IMO the aromas we get from cannabis are due to the terpene production that is associated with the resin.
Terpenes such as lemonene and terpineol are what make up some of the aromas we get from cannabis.
A terpene is not actually released by a plant like other flowers can do, and the aroma is emitted from the plant when the alcohol of the terpene is evaporating. Probably why we can smell a plant so strong when we rub against it and rupture resin sacks releasing the terpene's evaporating alcohol.
IMO the aromas we are getting is simply a consequence, and not a defense or attractant mechanism.
Since cannabis is wind pollinated I would lean more to a deterrent as I know may outdoor growers say once they flower everything seems to leave them alone, or as Baba Ku said a by-product. I wouldn't be surprised if they are anti-microbrial or have some other protective mechanism and just happen to have a smell we like.
The smell in Pot is due in part to terpenes (and other stuff) which are the precursors (building blocks) for the cannabinoids (i.e. THC, CBD, THCV etc. etc.). Whether there is a purpose to the smell I am not sure. I'm sure that man has heavily influenced the type of odor by selective breeding over the centuries.
-bakelite