The joke answer is that Sonic would not be able to run as fast if he wore pants. In official games, Sonic’s appearance is simply part of his character design.