How are in-air refuelling craft grounded to each other?
The metal of the tanker's boom (or drogue) contacts the metal of the receiver's receptacle (or probe) first, and that contact is maintained, so that would serve to ground the two aircraft to each other.

It's a good question, but I've never heard of any fuel explosions due to static buildup during air-to-air refueling, so evidently the systems in place alleviate the risks.  Aerial refueling is pretty routine these days, so in relative terms it would seem to be fairly safe.

Purging the fuel lines is a relative term; you could remove the liquid fuel from the lines, but you'd still have vapors, and those are more flammable than the liquid jet fuel itself.  Maybe somebody who flew (or flies) tankers can discuss how far down the boom the fuel goes BEFORE everything is connected and they start pumping; as a receiver I just remember that the fuel flowed into the manifold and then into the tanks.  We didn't do anything special to clear the manifold or fuel lines on our end.

There ARE some inherent risks when refueling between two aircraft flying in close formation that are accepted (i.e. the risk level is okay for the military mission, but nobody does it for commercial airliners), but I don't think this is one of them.