It is not illegal, but is not RoHS compliant either. This basically means that such solder cannot be used in consumer electronics meant for sale.
You can still legally use this solder for your own projects, as well as repair work and such.
The reason for its ban is concern with lead ending up in the environment, it does not pose a significant danger to you when you use the material, and it has been used as long as electronics exist. Ventilation has always been recommended and probably required when working with it profesionally, but that is required too when working with lead-free solders due to the fumes from the flux and such.