Amalgam (silver filling material) is a very strong metal that performs well under stress in molar teeth. The newer composite resin materials are not nearly as strong, and will require replacement every 5-7 years. See the image below how composite fails.
To stop the cycle of having to redo fillings so frequently (or worse if the failing filling leads to decay and the loss of the tooth), dentists use either porcelain or gold to restore the molar teeth. The entire old failing material is removed and a mold is taken. The porcelain or gold is then manufactured in the dental laboratory, and returned as an onlay. (There will be a temporary filling inside the hole in the mean time.)
Once cemented onto the tooth permanently, onlays perform extremely well under the daily stresses of chewing hard foods. They are shiny and smoothly shaped so flossing is a breeze. Truly a superior way to fill teeth. Onlays can last for decades.