Early humans (before they prepared anything) it was actually evolution that made sure we know what to eat. It's a gradual process that leads to a situation that most common things that are harmful cause pain and everything that's poisonos tastes awful and bitter.
In very simplified terms, if you as a human found something to eat and it tasted good, you probably ate a lot of it. If it was poisonous you just died. If you didn't like it you didn't eat it, so everybody that was genetically predisposed to dislike poisonous stuff didn't eat a lot of it and reproduced.
Pain is a similar story. Everyone not feeling enough pain stopped being careful and died.
What also adds into the mix is that humans are social animals that learn from each other.
Note that evolution is a very very slow process so a lot of things started out as instincts (like some animals that just avoid yellow-black striped animals). If this is important in your environment this instinct will get stronger and stronger until it turns into some sort of pain.
So regarding poisonos, if they are common in nature chances are pretty high that eating a little bit won't kill you and it will taste like shit.
Update: That's also the reason why sugar tastes so sweet and good. We evolved to like it because it was important for survival during a time you couldn't just go out and buy that stuff in bulk.
Not really. For example, even the worst mushrooms are only going to give you a tummy ache from a tiny nibble. And that's going to happen within a couple of hours. Not like 1/4 of a berry is going to drop you dead 3 days later.