I think it's because when I lose focus of my code, I will just end up listening to the video for like a minute, without having to even switch to my browser window. Without that, I would have the tendency to open Reddit/Twitter/this site whenever I get slightly distracted.
This of course requires picking videos that are both very long (don't want to go looking for a new one every 20min) and very casual (I don't want to have to actively listen to it).