AC line detection, with or without optocoupler?
... does using optocoupler have any advantages rather to simple RC circuit?


Yes, several.

It's not obvious from the schematic posted but the circuit GND has to be connected to mains neutral. This then means that you have to consider the whole circuit live. That means there is a risk of electric shock and that you can't, for example, connect to a programmer while the circuit connected to mains.

It may be tempting to think that the neutral will be very close to 0 V with respect to ground but various fault conditions can cause the 'neutral' voltage to rise. 


Polarity reversal. (Wired or plugged in backwards.)
Break in the external neutral (loss of neutral connection to your building or on the power to the circuit you are monitoring) can make your circuit neutral live.


I would go for opto-isolation unless the circuit was for mass production, was fully tested and there was no possibility of the user contacting the circuit. Otherwise use an opto-isolator.