Rama (Rabbi Moses Isserles (O.C. 432:2)) says that it prevents a bracha levatala. However, as to why ten, I have seen that it is used in order to be a significant amount. Chabad says that over and above various kabbalistic or mystical meanings, we use ten because it has become established as the common minhag.
As seen below, the difference between the ח of חמץ and the ה of מצה is the yud that is connecting the two parts of the ה to make it a ח Also note the position of the two letters in the word. The arrogance of the חמץ is replaced by the humbleness of the מצה as shown by the movement of the first letter into the end position. This י is symbolized by the ten pieces of bread that we search for and burn.
Rabbi Schneur Zalman of Liadi concludes that this is a custom, not
halachically mandated—but should still be respected out of deference
for its widespread acceptance as a hallowed practice. (Shulchan Aruch HaRav (O.C. 432:11)) Elsewhere,
Rabbi Schneur Zalman writes that searching for—and burning—ten pieces
of chametz has kabbalistic significance, as explained in the mystical
texts.3
In his glosses to the Haggadah, as part of his discussion on the
matter, the Rebbe explains that this custom has another important
function: On the morning before Passover we declare nullified and
ownerless all chametz “…which I have seen, and which I have not
seen...” These ten pieces of bread which we indeed saw and rid
ourselves of ensure the complete accuracy of this statement.4
Recently, I came across a beautiful explanation for this custom that I
hope you will enjoy as well. The number 10 is signified by the letter
yud—the tenth letter in the Hebrew alphabet. Yud (י) is also the
smallest letter.
On Passover we replace our "chametz" with "matzah." The two words
contain almost identical letters – albeit in a different order –
except that chametz is spelled with a chet, and matzah is written with
a hey. The difference between a chet (ח) and a hey (ה) is the almost
invisible pen-stroke that connects the foreleg of the letter to its
roof—signified by the י, the smallest letter in the alphabet.5
Chametz is pride and conceit. The flat matzah, on the other hand,
represents humility. Usually, it is easy to tell the difference. But
sometimes things are not so clear and the difference between the two
is hard to see—as small as a yud. On the night before Passover, we
search our homes and our hearts for the ten pieces of bread—the almost
indiscernible bits of pride which we have yet to identify.