I would say that even if they are not illegal where you are, it is stupid to remove one of your senses which could warn you of danger. When riding, ride. Listen to the environment and be safe.
To answer the point about deaf people riding, the fact is that deaf people have adjusted to not being able to hear and are more cautious, so are in fact usually safer than hearing riders. When you can normally hear and therefore can respond to dangers alerted to you by sound, but stick buds in your ears and add music, then you become far more likely to make a mistake.
Ear buds (in fact any music while riding) - just say NO!