It's a lot of things. I think the pickups is the #1 thing when it comes to electric tone.
I'm a pickup swapper and tinkerer and swap magnets to personalize my tone as well the pickups, pots and tone capacitors.
After that it's wood selection, nut material (plastic, bone, Tusq, Graph Tech, etc.), bridge and tailpiece materials and construction, tuners...even what the frets are made of.
I think of all guitars as being acoustic instruments, even solid body electrics.
Everything the strings touch and are connected to contribute to the overall tone.
Some people claim that the nut only affects the tone of the open strings but I disagree. If it's made out of sponge, it's going to affect the tone!
My experience has been that "magic" guitars, even solid body electric guitars, sound great unplugged as well as plugged in.
I agree, except I
might put the pickups second, because even though they affect the tone a lot, the guitar still tends to sound like itself with different pickups - a little different, but still the same guitar. The body and hardware modulate the string's oscillations, and we hear it,
Here's the long-winded explanation:
The string is plucked, oscillates and this is picked up by the magnetic pickups. But the oscillation doesn't happen in a vacuum. What's equally important, is the modulation of the string's oscillation by what the rest of the guitar is doing as it vibrates. And pickups are also microphonic. So there's an audio component besides the magnetic one, though it's
much smaller. Still one has to take that into account.
The pickups have a coloration/frequency response, and output a certain amplitude, but they can only pick up what the strings are doing when they oscillate - they're transducers.
We know the body and hardware vibrations modulate the oscillation of the strings after the pluck of the note, predominantly during the decay, sustain and release parts of the wave's progress through the ADSR envelope, because we can clearly hear it.
A PAF on a 335 sounds different from the same PAF in a Les Paul, and different from the same PAF in an SG, for example. It's all due to how the string is modulated by the body and hardware's vibrations as it passes through the ADSR. All of these types of guitar modulate the oscillating string differently.
Change the type of pickups on the same guitars, and the guitars are
still going to sound like a 335, and LP and an SG, the differences will be more subtle, more micro than macro.
Modulate a waveform, and it's going to alter the sound. It's just as true with guitars as it is with synths (I've got 40 years with synths so I tend to think in waveform terms - frequency modulation of a waveform is different from amplitude modulation is different from modulating with filters, resonators, choruses, etc, and they can all be combined).
I figure this modulation from the guitar itself is probably more important to the tone than the pickups, though obviously the pickups are very important as well.