Enjoying music doesn’t seem to have any obvious purpose. Sure you can argue it strengthens social bonds, but why specifically sounds arranged in patterns through time over anything else?
At least with humor you can say it’s about identifying the generating function of some observation which is sort of like reducing prediction error in predictive coding (and I suspect something like this is the basis for aesthetics) but I can’t fit music into being anything like this.
You might enjoy Kevin Simler’s review of Why Do People Sing?: Music in Human Evolution. It’s a beautifully written essay offering some speculative and surprising answers I don’t want to spoil.
Re: predictive error explanation: You might say that a good music piece needs the right balance of familiarity, emotional impact and surprise even when you are listening to it on repeat.
I don’t think I’m really looking for something like that, since it doesn’t touch on the perception of music as much as it does the reasons why we have it.