ESP32 destroyed by mosfet
Your MOSFET will not turn on fully with Vgs=3.3V. You can use a 74HCT logic gate with a 5V power supply to convert 3V3 into 5V. The input voltage thresholds of HCT gates will read 3V3 levels correctly with good noise margin. Use a gate resistor on the FET, like 1kohms, to slow down the switching.
Since the load is inductive, the FET absolutely needs a freewheeling diode. Otherwise, at turn-off, the inductor will create a voltage spike on the FET and it will avalanche, which will make it heat up quickly. Without heat sink, it will smoke, fail in short circuit, and fry the ESP32.