Indigenous people lived sustainably in the tropical Amazon rainforest for more than 5,000 years, a study shows.