The aerodynamics and hydrodynamics are extremely complex, but fortunately we need only to consider a more simplified view.
The result of the wind hitting the sails is either lift or drag.
Lift is the force created by the sails, exerted through the rig to the hull, acting perpendicular to the airflow.
In trimming the sails correctly, you can maximise this lift, and make the boat sail forward.
Drag is both friction (on the sails and rig) and air turbulence caused by the airflow over the sail.