Without electromagnetic coupling, the QM charged particle wave function is not invariant under a local gauge transformation — one with a phase that depends on space (space-time):
\begin{equation} \psi \mapsto e^{-i\alpha(x)}\phi \end{equation}
In order to turn on the electromagnetic coupling, we make the replacement
$$\hat{\vec{p}} \mapsto \hat{\vec{p}} - \frac{ie}{c}\vec{A}$$
This means that, in the Schrodinger equation is gauge invariant because the term arising from $\vec{A}$ is cancelled through the action of $\hat{\vec{p}} = i\hbar\partial$ on the phase factor $e^{-i\alpha(x)}$ in the wave function.
The math trick is clear. But physics cannot be understood from it, namely, why the requirement of local gauge invariance requires 1) the charge conservation 2) and the emergence of some kind of carrier of interaction.