I learned the lesson to this the hard way, by crashing into the back of a car. I was not paying attention to my riding due to the music coming from my Sony Walkman. The people in the car were okay, however, it was embarrassing to peel myself off their boot and then take my headphones off.
That act of taking the headphones off was 'the game is up' for the situation, the lady who had by now got out of her car knew what a fool I had been and why I had not been paying attention. Even though it was a low speed crash I still buckled the top tube and down tube of the frame and my bike did not handle properly after that.
Just like how every driver thinks they are one of the better drivers and not like one of those 'idiots out there', so it is with cyclists. Some think they are that good at riding that they do not need to be fully devoted to the task in hand and can listen to some music.
Another thing is that the music you listen to whenever you crash is forever damaged. You are listening to your favourite artist and the next thing you know, every time you hear that artist it reminds you of that crash and the stupidity involved in listening to music whilst cycling.
Music on a bike lulls you into a false sense of security. It also lulls you into believing that you are riding better than you are. Just because there is a 'techno beat' (or whatever) to ride to doesn't mean you actually are performing well. Just because you are listening to 'chilled out' music does not mean you are riding less aggressively/assertively than you would do otherwise.
Another problem with listening to music through earphones is the wind noise created by the earphones/headphones/whatever. You need to crank up the volume to 11 just to get half of it. It is established medical fact that music at this volume damages the little hairs in your ears that you need for hearing. What do you want to do that for?
None of us are smart enough to always avoid causing accidents when interacting with other road users and the minute this happens to you then you have to have a pretty good reason for losing control or not anticipating a situation. WEARING HEADPHONES IS NOT A GOOD ENOUGH REASON! DON'T DO IT!!!
Do note that none of the other answers in this thread are written 'with the benefit of hindsight'. When it all goes wrong for you due to listening to some pointless music whilst riding your perspective on the subject will change in an instant and you will never go back to listening to music on headphones whilst you ride on the public roads. Life is short enough as it is, really. [Lecture over!]