A sail is a vertical airfoil the same as an airplane wing, and the big secret (to non-sailors) is that sailboats have an underwater wing (that most folks don't see) called a keel, centerboard, daggerboard, or at least lee-boards that are much smaller that the cloth wing above.
Now imagine an airplane turned up on its side with one wing in the water and the other in the air, only the wing in the water is a lot smaller than the one in the air and you have the equivalent of a sailboat. The way the wing on an airplane is designed it is curved on the top and flat on the bottom. The leading edge splits the air so there is an airflow over the top and bottom, but the flow over the top is faster because the curved topside is a greater distance. Because the top flow is faster there is less air pressure and you get lift (it's called the Bernouli Effect).
When a sailboat goes up into the wind the sailcloth curves and makes an airfoil that creates lift on the backside (leeward side) and that's what makes sailboats lean over when going to winward. In Figure 1, the forces created by Bernouli effect are shown with bold arrows, both on an airplane and a sailboat.
On Figure 2; Because of the difference in pressure between the two sides of the sail created by the Bernouli effect, the boat is pulled in the direction of A. If we break down A into two parts, we get two “forces” in the directions of B and C. Since the keel (underwater wing) at the bottom of the boat checks the “force” that tries to move the boat in the direction of C, the boat has no choice but to move in the direction of B.
It's not 100% efficient as no sailboat can go more than 30 degrees into the eye of the wind (on either side), but that leaves 300 degrees of direction in which to sail. Actually when the wind is directly behind the boat, it does blow into the back of the sail and "push" the boat along, but strangely enough the boat does not sail as well "downwind" as it does across the wind. I call it the magic of sailing and it is one of the very few phenomenon in this world where you get something for relatively nothing. Soaring in a sailplane on rising currents of warm air (called thermals) is another case. One could argue for surfing and skiing, but there you have to swim out or get to the top of the slope before you can start. In sailing one cannot go directly into the wind, but it is possible to reach a destination which is directly into the wind by going at 30 degrees off the wind to the right, then "tacking" (or turning on the other side of the wind) to 30 degrees off the wind to the left. Seen from above the boat's path is the letter "Z", but the average track takes one directly up-wind, then you can have a nice ride back with the wind astern.
There are some techniques that you must learn to enjoy sailing and not "tump over". You must learn how to hold a proper course, come about, jibe, right the boat, and make a proper docking both in light and heavy winds. The prudent sailor also should know knots, navigation, meteorology, safety, and that a sail is not a "sheet" (a sheet is the line that controlls the sail). There are no "pulleys" and "seats" on a boat, they are ""blocks" and "thwarts". But once you have learned to sail your own boat, you will find that it's "habit forming" and it gets into your blood. And by the way you will certainly meet some of the nicest people in the world if you become a sailor.