It isn't just nostalgia at all. A large portion of Sonic's fanbase some people ignore (but is a MAJOR factor) is the mobile fanbase. Tens of millions of people playing Sonic games on mobile for free. Mario doesn't have many mobile offerings, and the ones that it does have aren't as big as some of the Sonic mobile games. Sonic Dash, for example, was downloaded half a billion times. Think about how massive that is.
Sonic Dash Hits 500 million downloads
Mario has him beat when it comes to console-based video games, but in terms of pervasiveness and reach, free mobile apps will do a lot for you. Kids might not be playing Sonic at home on a console, but they sure as hell are seeing him in the app store.