The Chaos Helmet is a magical weapon created when Mario uses a Fire Flower to charge up the Chaos Emeralds. Only Sonic can use the Chaos Helmet. When he does, it creates an impenetrable armor around him. This makes him Knight Sonic.
When the Wise Ones created the Chaos Emeralds, they accidentally added too much rainbows and not enough sparkles. Everybody knows that an unbalanced rainbow-sparkle ratio can lead to the creation of a magical helmet when charged by Mario's fireballs. Exactly this happened, and it allows Sonic to turn into Knight Sonic. This is yet another of Sonic's many forms.
The Chaos Helmet is extremely magical, and it is very powerful. Sonic likes to use it to be a knight, but the Chaos Helmet was only used twice. This is because Sonic and Mario despise each other. The first time was when Mario tried to attack Sonic, and accidentally hit the Chaos Emeralds. The second time was when Satoru Iwata forced Mario to make the helmet so they could beat Gaia.