Why do sailboats have to tack upwind?

Modern sailboats use sails that act as foils, with pressure that increases on the inside of the foil higher than the outside of the foil, similar to an airplane wing and described by the Bernoulli effect.  The sails must have an angle of attack that is perpendicular to the direction of the wind to be effective.  Off the wind, or heading away from the wind, the sails can be eased out to maintain this angle.  Heading into the wind, the boat can only get so close to the direction to keep the sails from becoming ineffective or "luffing."  So to head in the general direction of the wind, a boat must tack at angles to the wind, to make its way in the direction of the wind.