A sail is essentially an aeroplane wing standing on its end.
The principle of physics behind aerofoil theory is Bernoulli’s Principle. When wind comes in contact with the front of the wing, the air splits up and some air travels over the wing and some travels under the wing. Air travelling over the wing has a further distance to go than air that travels under the wing.
In order to meet back up with the same air at the trailing end, air that has travelled over the wing has to travel further, so must travel faster. According to Bernoulli's priniple, the pressure above the wing is lower than the pressure underneath, so the is a net force lift the wing, and in fact the aeroplane attached to it.
Much the same principle lies behind sails. When the wind blows and fills the sail, the sail becomes shaped like an aerofoil.
The boat as shown will feel a force due to the sail towards the upper left. The boat can be made to move forward by point the rudders so that the boat steers into the wind as shown below.