The hunter-gatherers knew about the edible fruits and vegetables from years of observation and trial and error.
Such people observed the taste and effects of the fruits and vegetables available to them, and passed on the information that they assimilated to others and their next generation. Over a period of time, such communities had enough information regarding the fruits and vegetables that they could consume as food items and the ones that they could not.