It's ultimately the same reason why light refracts, Huygens's Principle.
You're thinking of the sound as "a wave", in this particular case you're looking at it where its roughly linear. So then, why does this linear thing suddenly move sideways when it goes through a hole?
Think about it differently; according to Huygens a wave front is the mathematical addition of an infinity of spherical waves. You see a linear wave, but that's because you're macroscopic. At the microscopic level that's not what's happening, at that level its moving in all directions all the time.
So wait, if the microscopic "things" are moving spherically, then why did you have a linear wavefront to start with? Because over an extended front, every bit of the wave that's going, say, right, has another bit somewhere else going left. When you sum it all up, all the "sideways bits" sum to zero, and the only leftover terms are the ones from the original disturbance, moving outward.
So what happens at the slit? Well consider the spot right on the left edge of the opening... the left side of it is moving left and the right side is moving right (its spherical). Now before it got to the slit there was another spot to it's left that was doing the same thing. So the left moving bit of spot A was being cancelled out by the right moving bit of spot B. Ahhh, but B just hit the wall, literally. So no no one is stopping the left-moving side of A.
Presto, at our macroscopic level, it looks like it started moving left. But that's not "really" what happened.