What caused the corrosion
It looks like it used to be an aluminum lug not rated for wet locations. Add to it the dissimiliar metals involved adding to the degradation of the connection. Most grounding lugs for wet locations are made with bronze.
And add to that Well water