Just as in the title. The notation is somewhat surprising in its use of a superscript rather than a subscript, but I gather there is a history of using $M^n$ to refer to an $n$-dimensional manifold. Still, it is perhaps a bit awkward in leading us to say things like "$S^1 \times S^1$ is not isomorphic to $S^2$". The notation could perhaps be understood in the context of a smash product, but this is likely anachronistic.
Anyway, enough speculation. The question is simple: where does the use of $S^n$ to denote the $n$-dimensional sphere originate?
We know that on one hand mathematical notation was developing evolutionarily, sometimes even ad hoc. On the other hand, mathematics is huge, requires a lot of notation, so much notation that it is hard to keep it short. Thus, at least in practice, consistency is often not attained across different times and domains.