Like potatoes and tomatoes, coca plants grow wild in the Andes Mountains of South America; they probably evolved around the same time as the other flowering plants, around 120 million years ago. The plants make cocaine in their leaves, probably to keep animals from eating them.
When people first arrived in South America, about 13,000 BC, they probably started chewing coca leaves right away, because coca leaves, like coffee or cocoa, help you stay awake longer and work harder than you could otherwise, and helps you not feel pain, too.
People mixed coca leaves with powdered lime (burnt limestone) to make them less acid to chew. Doctors prescribed coca to both men and women to help with arthritis, cancer, or other serious chronic pain.
By the time the Valdivian people in Ecuador were farming potatoes, about 3000 BC, they were probably also farming coca. By 2000 BC, Norte Chico people were also farming coca. Moche and Inca people, in antiquity and the Middle Ages, also farmed and chewed coca. Inca rulers also sacrificed coca to their gods by burning it.
People chewed coca as far north as Nicaragua in Central America. (Further north, the Maya, Arawak, and Aztec chewed tobacco instead, also mixed with lime.) Across the Andes mountains in Paraguay, Bolivia, and Argentina, the Tupi and Guarani people chewed coca leaves too.