Why do people tap their foot to music? When listening to music, I often see people tap their feet either to the main beat or the dominating rhythm of the music.

Why do people do this?
Short Answer: 

People tap their feet due to increased activity in the cerebellum.

Detailed Answer:

There already is some evidence that music can release certain neurotransmitters, including dopamine. You can assume that people who tap their feet to the music, are in someway "pleased" by the music, meaning that their body goes into some sort of physiological joyride. Part of this joyride is an increased blood flow to the limbs, an increase in heart rate, dilated pupils, and most significantly a rise in activity of the cerebellum. 

There is also the theory that music can have similar effects as drugs &amp; addiction on the reward pathway of the brain. This pathway stimulates the flow of dopamine  to the striatum, which is a part of the forebrain, activated by reward, motivation and addiction. 
In addition those dopamine levels can already peak milliseconds before something "special" in the song starts (e.g the bass drop, guitar solo, etc.), which strengthens the theory that our brain anticipates and predicts upcoming events (such as the memory prediction framework). 

However, for example to songs the individual is completely unfamiliar with, the memory prediction framework may not be activated, therefore dopamine levels will not spike before the actual e.g. "drop", but after it happens, the striatum will be filled with dopamine. 
Furthermore, as mentioned in the beginning of the answer, the cerebellum gets more active as certain music is played, releasing neurotransmitters, and therefore the increased activity an individual is more likely to move their e.g. legs, because of a heightened motor-system. 

Sources: 


Adinoff, B. (2004). Neurobiologic Processes in Drug Reward and Addiction. Harvard Review of Psychiatry, 12(6), 305-320. doi:10.1080/10673220490910844
Blood, A. J., &amp; Zatorre, R. J. (2001). Intensely pleasurable responses to music correlate with activity in brain regions implicated in reward and emotion. Proceedings of the National Academy of Sciences, 98(20), 11818-11823. doi:10.1073/pnas.191355898