Necessity----years of trial and error. I forage and get a fair amount of information about the plants from historical usage in the native peoples of the area I live. i can't speak for coffee and tabaco but I believe it was a lot of trying this and that and then transfering the plant knowlegde thru the " shaman" . Even today we apply principles about plant families to get a desired result. It doesn't always work...but necessity and time created these items. Generations, not an individual.