Tooth decay is primarily caused by bacteria in your mouth that live on your teeth (the major offender is called Strep. Mutans) these bacteria convert sugar in your diet to an acid (lactic acid) as they grow. The acid is a waste product to these bacteria and thus they expel the acid, onto your teeth!
Your teeth are made of a mineral called Hydroxyapatite and this mineral can be dissolved by acid, you can see where this is going!
Usually your teeth sit in saliva which is protective but the acid from the bacteria can start to dissolve the structure of your teeth causing decay and cavities (holes) in your teeth. As the tooth is eaten away the bacteria progressively invade the tooth causing more and more destruction.
Although decay is caused by bacteria, those bacteria need sugar to grow and produce acids and thus sugar intake is a huge factor in a persons decay risk.
One quite overlooked aspect of sugar in your diet is very important:
Frequency of sugar: If you are frequently having small amounts of sugar this can be quite bad for your dental health and risk of decay as you are providing the bacteria with a steady stream of food.
Conversely if you only have sugar infrequently, it will get washed out of your mouth relatively quickly and the bacteria will go for long periods without food to grow and produce acid.
Fluoride acts by altering the structure of your teeth to change the regular hydroxyapatite structure to a stronger fluoroapatite. In fact it is 10 Times More Resistant to Acid. This is why fluoride in the water has been so important as when you were young you built your teeth with more fluoroapatite and thus stronger.
Also currently fluoride in the water and especially in your toothpaste gets incorporated on the outer surface layer of your tooth making this layer an extra resistant to decay.
So, drink fluoridated tap water and brush with a fluoridated toothpaste!!
Hopefully it goes without saying, but brushing and flossing are absolutely vital to your dental health. The action of brushing (with a fluoridated toothpaste!) cleans the colonies of bacteria (biofilms) from your teeth and prevents them from building up. It is important that this is done regularly (twice a day!) and thoroughly as bacterial biofilms mature they become more damaging and produce more acids.
By brushing your teeth you clean away the biofilm and allow the saliva to naturally re-mineralise (heal) the tooth structure. However if it is not done regularly decay can quickly progress to an extent where re-mineralisation is not possible. So regularity and thoroughness are key.