Without gauge invariance, the masses of vector bosons would be affected by contributions from higher order Feynman diagrams. As a result, even if the bosons have zero mass in the fundamental theory, their masses can become nonzero due to these contributions.
In the presence of gauge invariance, those diagrams that would have contributed to these changes in the mass cannot contribute thanks to the Ward-Takahashi identities. They cause those diagrams to become zero.
For more detail, one would need to look at the self-energy diagrams that would produce contributions to the boson mass and then see what the effect of the Ward-Takahashi identities are on those diagrams.