The primitive people learnt which are beneficial and which you should avoid by living between them for thousands of years, through trial and error and by teaching their kids "don't eat this plants because you'll die". They didn't understand it but they had to explain it somehow.
I got the feeling that you use "primitive" in a negative association. To be honest, I think our ancestors were more advanced in their relation to nature than the modern man ever will be.
There are kids in London that never have seen a cow in real life.
There are politicians that deny global warming.
There are entertainment on TV all the time, just so people do not react and argue, etc.
Our ancestors had a real close relation to the environment they lived in (the unpolluted nature). The Indian natives honored the animal that they hunted, by wearing their skin and take their names.
When did we honor the hen or the cow for all the food they bring us?
Of course some knowledge came from trial and error, not all people or tribes have had the ability to talk with plants. But to be honest, how much time would a native indian have? If there are 500 species out there and you need one, should you start 500 trials? On your tribe population of 50 people? Imagine instead a situation when a family member has a serious infection and are about to die before your eyes. You run out in the bush with the aim to find something that might cure the disease and spirit leads you to a plants that might help. So you return with that plant and mother prepares it for the patient.
Now the Vikings for instance knew to carry dried lingonberries when they sailed across the world. The sailors of the 16th century did not, so the later sailors got Scurvy (Scurvy is a disease resulting from a deficiency of vitamin C). The dried lingonberries contain vitamin C, and the Vikings in the 900th century and later, avoided that disease.
Wiki on Scurvy:
History Scurvy was documented as a disease by Hippocrates,[16][17] and Egyptians have recorded its symptoms as early as 1550 BC.[18] The knowledge that consuming foods containing vitamin C is a cure for scurvy has been repeatedly rediscovered and forgotten into the early 20th century.[19]
Early modern era "In the 13th century, the Crusaders frequently suffered from scurvy. In the 1497 expedition of Vasco de Gama, the curative effects of citrus fruit were known.[19] In 1536, the
French explorer Jacques Cartier, exploring the St. Lawrence River, used the local natives' knowledge to save his men who were dying of scurvy. He boiled the needles of the arbor vitae tree (Eastern White Cedar) to make a tea that was later shown to contain 50 mg of vitamin C per 100 grams.[20][21] Such treatments were not available aboard ship, where the disease was most common.
Between 1500 and 1800, it has been estimated that scurvy killed at least two million sailors.[22] Jonathan Lamb wrote: "In 1499, Vasco da Gama lost 116 of his crew of 170; In 1520, Magellan lost 208 out of 230;...all mainly to scurvy."[23]"