In my understanding, the evolutional function of berries is to be eaten and pood out somewhere else, so that the seeds of the plant spread. Is this so? Then why are some berries poisonous?
While poison affects not every organism equally, plants did develop some poisons to avoid being eaten. However, if you look at the great multitude of so-called secondary metabolites, most of them are poisonous to either viruses, bacteria, fungi or other microorganisms, or insects, or even other plants. Plant evolution just hasn't had time to adapt to humans.
So, if some substance from plants is a poison to us, it's accidentally so, and the target was another organism. Examples: nicotine is first and foremost an insecticide, nematistat, and herbicide; aconitine, atropine, caffeine are insecticides; many essential oils (causing allergies in human) are antimicrobial and so on.
This has also to do with the fact that nerve cell physiology has not much changed since they developed in the first multi-celled animals, and poisons for insect nerves have at least some effect on human nerves.