Good question, and the best theory (there's no solid proof) is that because of the decayed mylar insulation on the wiring, higher voltages from elsewhere in the plane's circuitry jumped to the pump wiring or (more likely) the fuel level sender unit wiring.
But the exact cause of ignition remains a mystery. There are several possibilities, but none of them is a solid lock. The official investigation admits this.
d.o.l.
Criminal Number 18F
Some folks around here will simply not accept that some occurrences are accidents, especially when there's a convenient political demon to blame.
exact cause of ignition remains a mystery
Aviator probably knows this, but to recap on how we keep planes full of potentially explosive stuff from exploding all the time:
To have an explosion in a jet-fuel tank you need to have several things:
... and, finally, the granddaddy of them all:
Before TWA 800 designers concentrated mostly on eliminating possible sources of ignition. Since, operational considerations include not having fuel tanks contain an inflammable mixture in the ullage, to give belt-and-suspenders safety.
A third level of safety will be added soon by inerting, by putting inert gas into the ullage so that the fuel can't evaporate and form inflammable vapor.
Hope this helps. The explosion thing is kind of counterintuitive (if it happened once, why doesn't it happen all the time? people ask). The answer is, too many odd details need to fall into place, which is why it's happened only four or five times in millions of flight hours.
d.o.l.
Criminal Number 18F