In ancient times, how did people figure out that certain things are edible? Did someone just pull a potato out of the ground and decide to see what happens if you cook it? Back a long time ago, no one had any FDA or laboratories, so I am very curious what measures people took to figure out if a certain food is edible. Also, how did people know they should cook it or keep it cold or whatever to make it edible if it wasn't already?
The same as any other animal does; by nibbling at it a bit and seeing what happens.
This kind of question is the subject of Chapter 7 (How to make an almond) of Jared Diamond's Guns, Germs, & Steel.
Almonds are held out as a particularly interesting case, because raw wild almonds typically contain enough cyanide to kill a person. However, there are occasional mutants that are edible, and hungry animals (including people) always found those.
Since the cyanide is the plant's protection from having its seeds eaten, this would normally be enough to kill off any of those mutants from the gene pool. However, humans brought something new to the equation. As hunter-gatherers with large ranges, at first humans who ate them accidentally spread the mutant almond trees around via their refuse dumps. Once they started planting their favorite food trees, obviously only the good mutant almond trees got planted.
Getting back to the oddity of someone trying a new plant, Diamond tells us for hunter-gatherers its not that odd at all:
... an entire field of science, termed ethnobiology, studies peoples' knowledge of the wild plants and animals in their environment. Such studies have concentrated especially on the world's few surviving hunting-gathering peoples, and on farming peoples who still depend heavily on wild foods and natural products. The studies generally show that such peoples are walking encyclopedias of natural history, with individual names (in their local language) for as many as a thousand or more plant and animal species, and with detailed knowledge of those species' biological characteristics, distribution, and potential uses. As people become increasingly dependent on domesticated plants and animals, this traditional knowledge gradually loses its value and becomes lost, until one arrives at modern supermarket shoppers who could not distinguish a wild grass from a wild pulse.
Whenever I have taken New Guineans with me to other parts of their island, they regularly talk about local plants and animals with other New Guineans whom they meet, and they gather potentially useful plants and bring them back to their home villages to try planting them. ... The first farmers were heirs to that knowledge, accumulated through tens of thousands of years of nature observation by biologically modern humans living in intimate dependence on the natural world. It therefore seems extremely unlikely that wild species of potential value would have escaped the notice of the first farmers.