This answer is good, but I wanted to pick one tiny nit, which is that not all music is built out of 7-note scales. A lot of music is, but music that isn't doesn't often lie well on the staff. That's true, incidentally, whether there are more than 7 notes in the scale (12-tone music, lots of octatonic music from people like Stravinsky, Scriabin, etc.) or fewer (whole-tone music comes to mind, as does the slightly more esoteric hexatonic scale). Pentatonic music fits well on the staff because the pentatonic scale is a subset of the ordinary diatonic.