Fluoride prevents tooth decay by strengthening tooth enamel and making it more resistant to acid attacks from bacteria and sugars in the mouth.