Remains of the sweets being taken may be present in between the teeth and bacteria acts on them at night producing an acid that causes decay of the enamel of the teeth. Toothpaste contains certain bases that help in destroying these bacteria and neutralising this acid, thereby preventing tooth decay.