It was in occasion of the visit of the King (and Queen) of the recently formed Kingdom of Italy to Naples.
The first pizza (pizza Margherita, so later named after the name of the Queen) "novelty" was not the tomato in itself, but rather the tomato together with mozzarella cheese and basil, as symbols of the three colours of the Italian flag, white, red and green.
Too bad that it is nothing but a story, pizza, including a version with these same toppings existed at least since some 100 years before:
https://en.wikipedia.org/wiki/Pizza_Margherita
though it was not particularly common, because the mozzarella cheese was costly even then.
Plainer pizzas (called by different names), with just tomato or only garlic and oil were common not only in Naples, with the exception of the cheese all ingredients (flour, water, tomato, garlic, olive oil) were ubiquitous and cheap not only in southern Italy, but all aroud the Mediterranean Sea.