Detect 220 VAC with a Raspberry Pi
If safety is a primary concern, rather than build that circuit up, you could consider purchasing a standard AC-input module for about $10-$15. They are UL, CSA, CE, and TÜV safety certified (it's still possible to go wrong and create a dangerous situation, especially if the wiring is sloppy, but less likely). 

Best to have someone knowledgeable look it over before you power it up in any case. 



The circuit inside the housing is somewhat similar to the one you show, however it will respond much faster. 



With regard to the circuit you show the PS2501 has a short-term isolation voltage rating of 5000V RMS. That is adequate to safely withstand the 240VAC mains and most transients that might appear on it. 

For safety you need to keep the creepage (surface leakage) distance between input and output leads (of the opto) to at least 8mm and make sure it can never get wet or otherwise contaminated with conductive materials. 

The circuit on the low voltage side should be earthed and fuses or other current limiting used so a failure of the opto cannot cause a hazardous condition. 
R1 and R4 may or may not be acceptable depending on the type. They can certainly burn up under some conditions. 

Without an earth connection on the isolated side you are depending on a few mils of plastic inside that opto for safety. 

As far as your other questions, the 90V rating is only the output transistor- in operation, it sees only 5V and the 240V input is reduced to the 1.2V the LED needs through the components to the left of the isolator. 

All the latter parts are electrically "hot" (including that side of the opto) and need to be well protected against accidental contact. 

The capacitor C1 MUST be an X2 type which is a safety certification for cross-mains use. R1 and R2 must be capable of withstanding mains voltage and transients. Vishay VR25, 35 etc. series is appropriately rated. 

C1 is what really does the work of dropping the 240VAC down to 1.2V. Most of the mains voltage appears across it. On positive half-cycles the current flows through the LED in the optocoupler, on negative half-cycles the current flows through the 1N4007. The resistors are there mainly to limit the current if powered up when the voltage is not zero.