Fluoride works primarily by enhancing the remineralization of tooth enamel, making it more resistant to acid attacks from bacteria in the mouth. It also inhibits the growth of harmful bacteria and reduces the production of acid, which can erode teeth.