This is a big debate and for the longest time the prevailing advice was to not allow access to soil.
A lot of people will tell you not to let them eat soil due to possibility of intestinal impaction.
I am one of the people who allows all chameleons to have exposure to substrate, in fact all of my enclosures are fully planted.
The soil is organic, fertilizer, perlite and pesticide free.
In my experience, once they are allowed to eat soil if they want, the behavior does not last long. It is also more prevalent in young animals.
I have never had an animal with an impaction issue.
-Brad