Amalgam has been used filling as dental material for cavities for the past 150 years. It's also called silver filling, mercury filling and black filling.
Even though it doesn't look nice cosmetically, scientific researches show that it's safe as dental material. It only needs to be replaced when it has defects, cracks, or decays. In this case, the amalgam was replace by the white filling (composite resin) because it had secondary dental caries.