It's a fact well-known enough to be the tagline to the 1979 sci-fi horror blockbuster Alien: "In space, no one can hear you scream." Or to put it another way, sound can't be carried in the empty vacuum of space - there just aren't any molecules for the audio vibrations to move through. Well, that is true: but only up to a point.
As it turns out, space isn't a complete and empty void, though large swathes of it are. The interstellar gas and dust left behind by old stars and sometimes used to create new ones does have the potential to carry sound waves - we just aren't able to listen to them. The particles are so spread out, and the resulting sound waves are of such a low frequency, that they're beyond the capabilities of human hearing.
As Kiona Smith-Strickland explains at Gizmodo, sounds travel as molecules bump into each other, the same way that ripples spread out when you drop a stone into a pond: as the ripples get farther and farther away, the sound gradually loses its force, which is why we can only hear sounds generated near to us. As a sound wave passes, it causes oscillations in the air pressure, and the time between these oscillations represents the frequency of the sound (measured in Hertz); the distance between the oscillating peaks is the wavelength.
If the distance between the air particles is greater than this wavelength, the sound can't bridge the gap and the 'ripples' stop. Therefore, sounds have to have a wide wavelength - which would come across as a low pitch to our ears - in order to make it from one particle to the next out in certain parts of space. Once sounds go below 20 Hz, they become infrasounds, and we can't hear them.
One example noted by Gizmodo is of a black hole, which emanates the lowest note scientists know about so far: it's about 57 octaves below middle C and well below our hearing range (about a million billion times deeper than the sounds we can hear). You'd expect to be able to measure about one oscillation every 10 million years in a black hole sound, whereas our ears stop short with sounds that oscillate 20 times per second.
Back on our own planet, the sounds of very strong earthquakes are sometimes intense enough to make it out into space, and infrasound can carry on going where normal sound has to pull up.
For a short amount of time after the Big Bang (about 760,000 years), the Universe was dense enough for normal sounds to pass through it. And if you hear the sound of a planet or spacecraft exploding in a Star Wars movie, remember that the filmmakers are taking liberties: chances are you wouldn't hear much of it at all.
Update 1 November: We had originally stated that sounds below 20 Hz become ultrasounds, which is incorrect. They become infrasounds. This error has now been fixed up.