You’re right that sweets aren’t good for our teeth but having one as the odd treat every now and then is not too bad. It’s if we eat them every day we get the problem.
And as I said, sweets taste yummy. This means that people buy them and so the companies that make them get money. If everyone stopped buying sweets the companies that make sweets wouldn’t make any money from them and so they would stop making them.