The cause of hallucinations are many.
Most of the time hallucinations are caused by functional deficits in the brain.
We have neurotransmitters in the brain. A very important neurotransmitter is dopamine.
The majority of antipsychotic medications block the absorption of dopamine -- they work to lower the amount of dopamine in the brain in order to reduce psychosis and hallucinations.
Too much dopamine speeds up nerve impulses which in turn can contribute to psychosis and hallucinations.
Schizophrenia is an example of a mental illiness where too much dopmamine is thought to contribute to hallucinations