This is one of gaming's oldest arguments, and both sides have a real case.
Sonic games lean harder into plot and character. There is a cast with actual personalities, a continuing world, and a story that carries across entries in a way Mario's rarely attempts. If you want a series with lore to dig into, Sonic has more of it.
Mario's strength is craft. The level design is meticulous and the difficulty curve is tuned so gently that a newcomer can pick up a controller and be competent within a minute, while the later stages still have plenty to offer a veteran. That accessibility is a design achievement, not a limitation, and it is a large part of why the series is so consistently well regarded.
Sonic's transition to 3D is the counterargument the other side always raises: the sense of speed that defined the original 2D games never quite translated, and a lot of the later entries landed as merely average.
So: Mario for design, Sonic for story. Which one is "better" depends entirely on which of those you value.