What is the function of an anticholinergic for mental illness?

Several. Anticholinergics first were used in psychiatry for treating parkinson's disorder, although other, more effective medicines have largely replaced them. They are perhaps most commonly used to treat side effects of other medications, especially antipsychotics, which can cause parkinsonsian-like symptoms. They also sometimes are used as calming agents in acute situations.