According to one playful origin story, Sonic's incredible speed came from an accident. He ran across Dr. Eggman's house, one of Eggman's inventions exploded, and Sonic's shoes caught fire and turned red—leaving him faster than ever.
It's a fun bit of Sonic lore, even if the games themselves keep his super speed a bit more of a mystery.