It is alleged that the archetypal pizza of the kind was invented in 1889, when the Royal Palace of Capodimonte commissioned the Neapolitan pizza maker to create a special pizza for Queen Margherita's visit. He created 3 different pizzas. Of these 3 pizzas he cooked, the Queen selected the one swathed in the colors of the Italian flag: red (tomato), green (basil), and white (mozzarella). That is why this kind, which is loved all over the world, of pizza is thought to be named after the Queen.

More Info: en.wikipedia.org