The problem with the relay could be the higher coil current and you need one with gold plated contacts for small currents.
An opto-isolator is probably the safest and easiest solution.
A single resistor could work but as others have stated, it could cause problems if the 0V rails aren't well connected.
Firstly, and importantly, you are have omitted the limited context in which that statement was made.
Secondly it can be argued in either direction (without knowledge of the operating environment and objectives), for example...
The problem with optoisolator could be the sensitivity to reverse voltage spikes or overcurrent spikes, or temperature range, or high speed response transmitting a noisy signal.
A relay is probably the safest and easiest solution.
For the avoidance of doubt, I don't believe "a relay is probably the safest and easeist solution" any more than I believe "an optocoupler is probably the safest and easiest solution". The system context and objectives are needed to discriminate between the two.