Flaps are retracted on the ground to reduce the variable wind speed and harmonic vibrations a plane often encounters on the runway. It's possible not to retract them, and there are a few, usually older, ex-military pilots who prefer to leave them down until reaching the gate. Many airlines have, more or less, "grandfathered" these pilots in not forcing them to retract the flaps on the ground.
A secondary benefit of retracing the wings is to reduce the risk of friction-based heat near the fuel tanks in the wings. There has never been a documented case of such friction causing an ignition of fuel, but the consensus is not to tempt fate.
Finally, most airline marketing executives think it looks weird to have the flaps down while on the ground, and it might cause observers to choose another airline that uses the fully retracted approach on the ground. And yes, I'm making all of this up.