It’s a computer-generated voice that doesn’t sound natural in the first place. When we hear speech, we rely on resonances in the acoustics that we call formants — in this recording, the lower formant frequencies are perceived as “Laurel,” but the higher overtones (which are louder than they should be, which is part of why it sounds so artificial) make it sound like “Yanny.”
Whether you hear one or the other depends on the device that you are using as well as your own ears’ sensitivity. A tinny-sounding speaker like a cheap radio or the built-in speaker on a phone will make it sound like “Yanny,” but a better quality speaker (or noise-cancelling headphones or anything that amplifies bass tones) will make it sound like “Laurel.”
Also, younger and smaller ears are more sensitive to the higher frequencies, so they will have a better chance of hearing “Yanny.” Someone with mild hearing damage (from earphones, working in loud environments or just from aging) will be more likely to hear “Laurel.”
Personally, I heard “Yanny” on a cheap PC speaker, but “Laurel” on better earphones myself.
I believe the original recording was intended to be a synthesis of “Laurel,” but the speech generation method in this case was just kind of shoddy — leading to the very understandable misperception. Also notable is that people who don’t hear “Laurel” vary in what they do hear; Yanny, Yarie, Yammy, Yalie and so on.
Here are a few more links for longer explanations from people more expert than me:
Bob Kennedy is a lecturer in the Department of Linguistics at UC Santa Barbara.