Bacteria turn sugar on the tooth into acid, the acid dissolves minerals from enamel, and saliva puts them back. Decay depends on how long the tooth surface sits in acid each day, so both how often you eat sugar and how much count.
Fluoride blunts the harm of each acid spell on the teeth, but it does not make sugar irrelevant. It reacts with enamel to form fluorapatite, which dissolves less readily, lowering the critical pH at which the tooth starts to dissolve. It also makes early lesions remineralize faster and more fully.