It doesn't. And, generally, it is not recommended. But if you understand the mechanics behind this idea, you may consider doing it and get some, although little, benefit.
It is important to note that humans cannot learn anything while sleeping. There is no research that suggests that we can. As far as I know, the idea was popularized by the old AJATT website. AJATT is about mass immersion, doing Japanese all the time. The reason why some AJATTers have Japanese audio playing when they sleep is not because you can learn something while you sleep, but because you will be hearing Japanese speech just before falling asleep and just after waking up. You can be exposed to the language more by doing this trick. If you pause Japanese before going to bed, there will be some time, maybe just a few minutes, when you are not immersing.
The other side is that any additional learning progress that could be made by the extra listening time will be canceled out by low-quality sleep. Playing audio while you're trying to sleep can disrupt you. If you're constantly being jolted awake by the audio, you're not going to get the restorative sleep you need to function at your best. Sleeping properly is an essential aspect of the language acquisition process and should not be compromised. A solution would be to use some technology to pause the audio after falling asleep and resuming it just before it's time to wake up. For example, an alarm clock app that has a feature to trigger a podcast app or a music app instead of playing a preset alarm sound by itself.