How to control optocoupler and relay by using microcontroller
You can replace the FET with the optocoupler if it's maximum rated collector current is higher than the current drawn by the relay's coil and if it's collector-emitter breakdown voltage is higher than the voltage you are using to power the coil. But remember to keep the MCU ground and relay ground separate if you use optocouplers otherwise it defeats the purpose of the isolation.
You cannot use 220V AC to power a dc coil relay. If you want to use AC you can use a triac instead of a relay and a triac-output optocoupler, but then the load has to be AC too, otherwise the triac will stay "on".


NOTE: If you use a relay, remember to add a flyback/free-wheeling diode reverse biased toward the 24V source to avoid inductive voltage spikes that will fry the opto.