The answer to this question is somewhat complex and not 100% understood by scientists.
The chemicals in "shrooms" that produce the high are called psilocybin and psilocin (and some trace similar compounds). When you eat mushrooms, psilocybin is converted into a chemical called psilocin. Psilocin is then absorbed into the blood stream where it is taken to the brain.
Psilocin has a chemical structure very similar to the naturally occurring neurotransmitter serotonin. Neurotransmitters are chemicals that cells in the brain (neurons) use to communicate with each other. Varying levels of serotonin will affect sleep, appetite, sensory perception, temperature regulation, pain suppression and mood.
Serotonin is taken up or absorbed by neurons at receptor sites known as the 5-HT receptors. There are various types of 5-HT receptors, but for our purpose we'll generalize. Because psilocin's chemical structure is very similar to serotonin, it is taken up by the 5-HT2 receptor site (one of several 5-HT receptor types) as are many other common hallucinogens including LSD and mescaline.
After the psilocin molecules bind with the 5-HT2 receptor sites, little is known about what happens. Psilo(cybin)cin is considered a serotonin agonist and possibly may have reuptake inhibitory effects also(SSRI) .There is still not enough data to explain clinically exactly the effect of the active ingredients in psychedelic fungi. What we do know is that psilocin is NOT physically harmful to the body or brain. Psychological conditions can rarely arise from a very profound experience, but no physical harm is done by psilocin even in higher dosages.
In short: psilocin molecules from the mushrooms bind with serotonin receptor sites in the brain and cause the mind to do strange things and scientists aren't quite sure why.