Why do plants produce so many terpenoid compounds?

Link. Cannabis is only one of innumerable terpenes. Presumed chemical warfare but not well understood.