Don’t have any dash, dome or tail lights when headlights are on?
When the wrench touched ground while on the nut, it briefly completed a circuit.
Current flowed from the battery positive to the battery ground terminal.
If you had held it firmly against the ground it would have been a good connection and as many electrons as possible would have moved through until...
that fuseble link melted.
That's what its for. To prevent a major melting of other wires if the battery is accidently grounded.