Before refridgeration was developed, food rotting was a major problem in the hot, humid tropics. The solution was to poison the food with spice - it would be somewhat unpleasant to eat, but would kill pests. I suppose over the years we got used to it.
Fun fact: English has words for four basic tastes (sweet, salt, sour and bitter). Indian languages have a fifth basic taste - chilly or spicy.