You have not mentioned the relay solenoid current.
IYour 1M resistors are too large to be useful here, you should reduce them to 100k at the most. I would actually suggest a slightly better arrangement:
simulate this circuit – Schematic created using CircuitLab
Both resistor values can be increased, but they should follow each other's values; if you increase R1 to 1k you should also increase the R2 to at least 22k, so that the driving voltage is not significantly reduced due to voltage divider formed by R1 and R2.
This brings up another issue: is your GPIO output voltage sufficient to turn the MOSFET completely on?
I would be wary of using a resistor in series with a freewheeling diode across a relay solenoid because the current spike is high and could produce a high voltage spike across the resistor which would defeat the purpose of the diode. A zener diode in series with a regular diode would be better because it would only conduct the highest voltage spikes and the relay would function better (a plain diode across relay coils is bad for the relay switch contacts, according to this short article:
Coil Suppression Can Reduce Relay Life).
The zener diode needs to have a voltage rating between the supply voltage and the MOSFET's maximum Vds rating so that the spike never goes above it. For example, if the supply voltage is 24V and the Vds(max) is 60V, the zener voltage should be between 30V and 40V. The power supply voltage should not be reaching the zener voltage (if you have an unregulated power source).
The zener diode should have the highest power rating you can get. 0.5W and 1W will not be enough. You could also use more than one zener and share the voltage drop (as well as the power) across them equally, and then you could use lower power zeners.