It's there to limit the peak current through the driver triac.
In the datasheet for the MOC3043 this is given as 1A. So for a 115V RMS line with a pk-pk of ~170V, a resistor of around 180 ohms is suitable. The 330 ohms given is more suited to a 240V line, but if it works okay for your application then fine - the resistor value also sets the turnon angle, and too high a value may prevent the power triac getting enough gate current to turn on fully.
This App Note has some good info on (optocoupled) triac driving.