Quite possibly the earliest form of herbal medicine was marshmallow root, which is a common grass chewed for settling an upset stomach, and has been eaten for (presumably) that reason by our closest evolutionary cousins, chimpanzees and bonobos. Likewise, hyacinth (a diuretic) causes the tissues to give up excess water, is rich in tannins and alkaloids, which have a bitter, or pungent taste.
As tribal human societies grew, a small body of knowledge over what plants were beneficial for what ailments grew, until the role of a tribal herb lore specialist became known; often times, in hunter-gatherer societies, this carries a lot of weight in the day to day running of the tribe.
As human societies shifted to an agronomical view of the world, the cultivation of plants for medicine was an important role in this; eventually, lore and herbal remedies became codified, first with the Egyptians, then with the Greeks in the Western tradition, and the knowledge base was slowly accumulated upon by the Romans. It's from the Greeks in particular that the foundation of modern medicine – of not just prescribing a treatment, but recording what the treatment was, and what its impact was, got started.