For our ancestors, the appendix most likely evolved to help them digest a diet rich in raw vegetables and cellulose, as it still does in many herbivorous mammals. Thousands of years ago it would have functioned as an extension of the cecum, involved in the bacterial digestion of fibrous plant materials.
This article says it was for raw vegetables: