Moving through the air, wings as well as sails are an obstacle to the air.
Air near the wing is delayed relative to an undisturbed air. Also, air that passes above the wing arrives at the trailing edge early compared to corresponding air that passes below the wing (see the colored arrows).
The change in speed is temporary. As the air reaches the trailing edge and thereafter, it quickly returns to its original speed.
Lift is proportional to Angle Of Attack. At zero angle of attack, wings and sails produce zero lift because there is no change in speed between above and below the wing. At too large angles, the air flow cannot follow the airfoil curve. When the air flow is separated from the airfoil (Stall), there is a sharp reduction in lift and an increase in drag.
Optimum AOA for wings used for sailing is about 10 degrees while optimum AOA for sails is about 20 degrees.