This i believe has to do with aerodynamics. A sail works just like an airplane wing, if you point the boat against the wind, the sail will have a curve like an airplane wing. Lets say that this bulge is towards the left. So air will flow faster at the left side and slower at the other because it has to travel a greater distance to get to the other side. Just like an Airplane wing(i know i keep repeating this but its exactly the same principle). So the air going faste will have less
pressure than the slower moving air. And so if you take the pressure difference and multiply it times the area of the sail you will see that the force will actually push it forward against the wind.
If this doesnt make sense look at my diagram i am about to submit
Sincerely,
FoxCommander