Asbestos is an amazing mineral. It is phenomenal as a fire retardant material, which is why it got so widespread. It took time and studies for us to truly understand exactly what the repercussions to using it are, and then implement appropriate controls (and phase it out). Similar with leaded gasoline (although maybe less so, depending on how complicit the oil companies were).
In any case, with all three of these things, it's not like we instantly knew how bad for us and the environment they are and how to appropriately handle them. There's a very constant iterative process to improving safety standards. Those barrels were likely dumped in the sea because we knew the contents could be harmful to humans. We neglected the environmental impacts because those weren't as highly prioritized, studied, or cared about. Processes change over time, and huge progress is seldom realized overnight.