This piece in the Boston Globe has a few answers.
Overall, it says, our primitive ancestors created music for probably one of three reasons:
1. For males to impress females ("Hey, babe, nice fox hide. Say, I'm in a band. Yeah, we just jam together, bang a few rocks, blow through a few hollow bones. . . .")
2. Lullabies mothers sang to soothe their children as they worked a few short feet away ("Baby mine, don't you cry, I'm over here picking rice. . . .")
3. Community anthems ("Our Grass Hut is a great Grass Hut. . . .")
But if we're to believe the historical accuracy of this, from James Lileks' site, music was one of the things that filled the time people suddenly had because they no longer had to always hunt for an animal to kill and eat: all they had to do was harvest grain, let it dry, grind it up, and turn it into beer, which they drank so they could, according to the Official Bread Story, get up the nerve to go to the next cave and steal their neighbors' bread.
And a few pages later, we find the astounding direct connection between bread and music. The connection between beer and music had already been well-established.
Next up: why we love sugar beets.