Gauge transformations φ → φ + ∂λ/∂t, A → A - ∇λ leave E and B and all physics unchanged. This gauge freedom reflects the redundancy of potentials. Gauge invariance is a profound symmetry principle underlying both classical and quantum electromagnetism.
From your study of scalar and vector potentials, you know that the physical fields are defined by E = −∇φ − ∂A/∂t and B = ∇×A. These definitions express E and B in terms of the potentials φ (scalar) and A (vector), but the key question is: are the potentials uniquely determined by E and B? The answer is no — there is an infinite family of (φ, A) pairs that all produce the same physical fields, and transforming between them is what gauge transformation means.
Suppose you change the potentials by φ → φ − ∂λ/∂t and A → A + ∇λ for any smooth scalar function λ(r,t). From your multivariable calculus, you can verify that the new B = ∇×(A + ∇λ) = ∇×A + ∇×(∇λ) = ∇×A = B unchanged, since the curl of a gradient is always zero. Similarly the new E = −∇(φ − ∂λ/∂t) − ∂(A + ∇λ)/∂t = −∇φ + ∇(∂λ/∂t) − ∂A/∂t − ∂(∇λ)/∂t = −∇φ − ∂A/∂t = E unchanged, because partial derivatives commute with the gradient. Both fields are invariant under any choice of λ — this is gauge invariance.
This freedom is not a flaw or an accident — it is a deep redundancy in the description. The potentials contain more degrees of freedom than the physics requires, and gauge transformations navigate between equivalent descriptions. This freedom can be exploited to simplify problems by choosing a convenient gauge. The Coulomb gauge (∇·A = 0) is natural for static or quasi-static problems; it makes A transverse and simplifies the equations for radiation. The Lorenz gauge (∇·A + (1/c²)∂φ/∂t = 0) treats space and time symmetrically and is the natural choice for radiation problems and relativistic contexts, since the condition is Lorentz-invariant.
Gauge invariance has consequences far beyond calculational convenience. In quantum mechanics, the wavefunction picks up a phase factor e^(iqλ/ℏ) under a gauge transformation — a local phase change that varies in space and time. Demanding that physics be invariant under such local phase changes (local gauge invariance) turns out to uniquely determine the form of the electromagnetic interaction: the photon field must couple to charged particles in precisely the way Maxwell's equations specify. This argument generalizes: the entire Standard Model of particle physics is built on the principle that physical laws must be invariant under local gauge symmetries — making gauge invariance one of the most powerful organizing principles in all of physics.