Bacteria in our mouths use sugars as their food source. The bacteria that cause tooth decay are unable to use proteins, fats or fibre to survive. Consequently a diet high in whole grains, meats, fish, fresh fruit and vegetables & dairy foods is a diet that is unlikely to contribute to tooth decay. Incidentally, this is also a diet most nutritionists would recommend for good overall health.
Once the bacteria in our mouths have used the sugars in our diet, they produce acid as a waste product. It is actually the acid that softens the hard outer shell of the tooth (enamel). Eventually the enamel cavitates and the bacteria enter the tooth. The process of acid softening happens every time we eat something with sugar.