Toffomat's answer is a great answer. Let me try to add a little bit more physical motivation for what it means to "decouple the ghosts."
SUMMARY: The requirement of gauge invariance comes out of trying to describe a relativistic theory of quantum particles with local Lorentz-invariant field theories. Specifically, trying to construct a local field theory of spin-1 particles is surprisingly challenging, and one of the few ways to make it work is to adopt gauge invariance.
LONG ANSWER: We believe that particles are ultimately irreducible unitary (or projective) representations of the Poincare group. The math works out so that these are defined by an energy-momentum relation $p^2 = m^2$ together with a unitary irreducible representation of $SU(2)$ (ignoring massless particles for now). These are the familar "spin-0", "spin 1/2", etc. representations.
On the other hand, we believe that to represent local dynamics for these particles we need to describe the equations of motion for the particles using fields, specifically using field functions that are irreducible representations of the Lorentz group. Despite sounding similar, this is actually a very different requirement than the one above. Unitary irreducible representations of the Poincare group are unitary but infinite-dimensional. Irreducible representations of the Lorentz group are finite-dimensional but non-unitary.
Most importantly, irreducible representations of the Lorentz are equivalent to irredicuble representations of $SU(2)\times SU(2)$. So while particles are naturally "spin 1/2" or "spin 1", fields are naturally "spin 1/2 times spin 1/2"
To construct a local field-theory of relativistic particles we have to overcome this mismatch.
The big idea is that we have to find subset of the field variable that corresponds to the particle representation. In the case of spin-0 it is easy. Representation theory tells us that "spin 0 times spin 0" = "spin 0" and so making the correspondence is simple. Spin 1/2 is also pretty simple. Dirac spinors are basically the field representation "spin 1/2 times spin 0" = "spin 1/2"
We first encounter a problem with spin 1. You can try "spin 1 times spin 0" = "spin 1" and this is valid, but it gives you unfamiliar equations of motion so no one is very interested in it. This would correspond to trying to make $F_{\mu\nu}$ your fundamental fields.
The other thing to try is "spin 1/2 times spin 1/2", which corresponds to a vector field $A_\mu$. The problem is that in terms of representation theory "spin 1/2 times spin 1/2" = "spin 1 plus spin 0." We want to make the "spin 1" part correspond to our particle, but we have to deal with the extra "spin 0" without introducing an extra particle. The first thing to try is separating out the spin 1 part of the field, for example $A^i$, from the spin 0 part, $A^0$, and treating them separately, writing equations of motion (or a Lagrangian) that doesn't have the spin-0 part in it. But that doesn't work because this separation is not Lorentz invariant. There are Lorentz transformations that mix $A^i$ and $A^0$, but Lorentz transformations can't change a spin 1 particle into a spin 0 particle.
But there is a way around it. You start with some separation of $A^\mu$ into a spin 1 part and a spin 0 part and ask how those parts mix into each other when you do a Lorentz transformation. Then if you can find equations of motion for the spin 1 part with no equations of motion for the spin 0 part and those equations of motion are invariant under the mixing transformation then you have equations of motion that really do describe just one spin-1 particle without the extra spin-0 particle.
If you do this for a vector field you find that the mixing term you have to avoid is $A_\mu \mapsto A_\mu + \partial_\mu f$ where $f$ is some arbitrary function. This is the requirement of gauge invariance.
But this is not the only solution! One might ask whether there other ways to do it. It turns out that the most general way to have a theory of spin-1 particles using vector fields is to have a theory that is invariant under local non-abelian group transformations in exactly the Yang-Mills theory.
Weinberg does all the gory details of this proof in his quantum field theory book. I believe Schwartz's book "Quantum Field Theory and the Standard Model" also gives a good summary of this argument in his early chapters. He phrases it in terms of "degrees of freedom," referring to the mismatch between the "spin 1" particle and the "spin 1 plus spin 0" field. I believe my outline here is cribbing heavily from him.
Note that this whole problem exists even for massive spin-1 particles. Gauge theories naturally lend themselves to describing massless particles because the natural mass term $m^2 A_\mu A^\mu$ is not gauge-invariant, but vector-field theories of massive spin-1 particles must also be gauge-invariant, leading one naturally to Higgs theory etc.