Your triac is upside down in the schematic.
- To trigger the triac you have to bring the trigger positive or negative with respect to terminal T1 (the terminal on the same side as the trigger on the schematic).
- Your "not work" schematic shows you shorting out the trigger pin to T1 so that does nothing.
- In your "work" schematic turning on the opto-coupler connects the trigger to the voltage across the triac. Since this is high enough the triac turns on.
simulate this circuit – Schematic created using CircuitLab
Figure 1. The WORK and NOT WORK schematics redrawn for clarity.
You are confusing operation of a trigger derived from the mains to one where a separate voltage is used. Figure 2 shows how this would work but note again that the trigger voltage is with reference to terminal T1 (the same side of the triac as the trigger pin).
simulate this circuit
Figure 2. Switching a triac with a separate trigger supply.
Finally, for reference:
Figure 3. Triac triggering modes and quadrant numbers. Source Wikipedia (with addition of numbers).
Note that your circuit works on quadrants 1 (both mains and trigger positive) and quadrant 3 (both negative) only.