The standard way is to require multiple failures rather than a single failure to put you into an unsafe condition. This is called redundancy.
The simplest way to do this with optocouplers is to use two separate outputs in series, so they both have to be on to create a '1' condition at the dangerous machine. The machine input needs a pulldown, or preferably two in parallel (so either can fail open), to maintain the input at '0' when power is off or the control cable is disconnected.
How you drive the optos depends on what you trust. If your software and MCU are impeccable, then you could drive both with one output. If you don't trust the MCU fully, then you could duplicate your MCU, use one to drive one opto and the other to drive the other.
This is assuming that you are trying to protect against some defect or random influence shorting the output device in the optocoupler. If you are worried about a malicious person tampering with the wires from your switch, then you need a whole different level of protection.
How far you go with the duplication and diversification is up to you. For instance, a package with two optos in it would satisfy output transistor duplication, but not package duplication, which would need two singly packaged optos. Some people would suggest not using the same make of opto, or the even the same technology, and make one of them a digital isolator, or a mechanical relay. In order to protect from a threat, you need to be very clear about exactly what it is and where it's coming from, and how much improvement you want in the likelyhood of no system failure.