The LED in the opto-coupler is turned on by R5 which turns on the opto-transistor so its collector is low. Then transistor Q1 is turned off causing its collector to be open.
R3 is in series with R6 which gives base current to Q2 that is turned on and its collector (the output) is low.
R4 causes feedback between Q1 and Q2 making them a Schmitt Trigger. Then they switch on and off very quickly with a "snap" action.
I redrew the circuit to show its true usefulness, namely to provide optically-isolated coupling where the input circuit does not have to be tied to the ground on the output circuit.
Note how the Schmitt Trigger squares up the slow edges of the input signal.