Jonah Lehrer explains:

The brain is designed to learn by association: if this, then that. Music works by subtly toying with our expected associations, enticing us to make predictions about what note will come next, and then confronting us with our prediction errors. In other words, every melody manipulates the same essential mechanisms we use to make sense of reality.

The second takeaway is that music requires surprise, the dissonance of "low-probability notes". While most people think about music in terms of aesthetic beauty - we like pretty consonant pitches arranged in pretty patterns - that's exactly backwards. The point of the prettiness is to set up the surprise, to frame the deviance. (That's why the unexpected pitches triggered the most brain activity, synchronizing the activity of brain regions involved in motor movement and emotion.)