Why do optocouplers require a resistor at the collector?
With R1 set to 0 Ohms, the optocoupler can draw a current as usual. But that won't produce any voltage variation at the oscilloscope input. Because the 'scope will be essentially short circuited to a voltage source.

When R1 is nonzero, the optocoupler current flows through the resistor and is converted to a voltage according to Ohm's law: V = I R. This voltage variation is what the oscilloscope is able to measure.