I recommend reading the thread at the link provided for troubleshooting suggestions and a detailed description of causes. A new sensor is not likely needed. Most supervision errors are due to the potential causes described in that thread.
It seems strange that this has just started after 2 years of no issues - what should be tried in order remedy before deciding to replace the sensor?
As borderline low battery is a potential cause, replacing the battery is the first step to try. It is normal for supervision errors to occur first when battery starts getting low, especially if other potential issues are there, like range, or metal in the immediate vicinity.
Also - why does the signal work fine/connect/reconnect when the door is open and closed but fails randomly otherwise?
This is actually normal. Supervision is a periodic heartbeat signal, the most frequent signal most sensors will transmit to the panel. These are more likely to be noticed failing first in borderline signaling cases.