I am learning gauge theories and I am a little confused with things.
I would like to take the simplest example : the $U(1)$ invariance to check if I understood the basics.
When we work with electromagnetism, we know that we have a gauge invariance :
$$ A_\mu \rightarrow A_\mu + \partial_\mu \alpha $$
The E.O.M are unchanged if we change like this the potential vector.
So, what we want is a Lagrangian invariant under such transformation. In practice, the E.M lagrangian :
$$ \mathcal{L}_{EM}=F_{\mu \nu}F^{\mu \nu} $$
is invariant under thoose gauge transformations.
Now, we want to couple this field to the matter, so the most general Lagrangian we write is :
$$ \mathcal{L}=F_{\mu \nu}F^{\mu \nu}+\partial_\mu \phi^* \partial^\mu \phi + \mathcal{L}_{int}(\phi, A)$$
As the electromagnetism is gauge invariant, the total Lagrangian must also follow this symmetry. Thus $\mathcal{L}_{int}(\phi, A)$ must be gauge invariant.
Finally, the simplest Lagrangian that follows the gauge invariance is :
$$ \mathcal{L}=F_{\mu \nu}F^{\mu \nu}+D_\mu \phi^* D^\mu \phi$$
Where $D^{(A)}_{\mu}=\partial_\mu + ig A_\mu $.
And we know that under a group transformation $g \in U(1)$, we have by construction :
$$D^{(A')}_{\mu} (g \phi) = g D^{(A)}_{\mu}(\phi) $$.
First question : Link between $U(1)$ symmetry and vector potential.
If we say that we have $U(1)$ symmetry here, it is because to change the vector potential $ A_\mu \rightarrow A_\mu + \partial_\mu \alpha $ is equivalent to act on $\phi$ with an $U(1)$ element : $e^{-ig \alpha(x)}$.
So finally, to talk about $U(1)$ invariance of this Lagrangian, or gauge invariance of the potential vector $A_\mu$ is just the same thing said in two different ways.
Also, it is by construction a local gauge symmetry because $\alpha$ can of course depend on space.
Am I right ?
Second question :
If I am right with what is written above, to try to write an $U(1)$ gauge invariant Lagrangian makes sense because it is linked to the gauge symmetry of electromagnetism (that we know well with maxwell equations).
But in gauge theories we also look for $SU(N)$ symmetries. How do we know from a physical point of view that it is the "good" group of symmetries ? For $U(1)$ it can be seen (if I am right with what I wrote) because of the gauge invariance of electromagnetism that we know from maxwell equation. But for QCD for example what is the intuition behind knowing it is the $SU(3)$ group of symmetry ?
Did theoretician just got their inspiration for electromagnetism and wondered what would happen if we write lagrangian following more general symmetries. They tried with $SU(2)$ and $SU(3)$ and saw that it indeed fitted to some experiments ? (I'm almost sure it wasn't like that but this paragraph is to try to explain better my second question).