The simple answer is wind. The more complete and complicated answer is solar radiation from the sun shining on the earth as it rotates, creating differential heating/cooling and therefore winds. Here’s a much more detailed explanation.
Wave height is determined by the strength of the winds, how long they blow, and the area or distance of ocean (fetch) over which they blow.
For big waves, you want an extended time of strong winds, blowing towards you over a large area of ocean. The wave period (time in seconds between waves) tells you how far away the waves came from. A large storm thousands of miles away will generate waves with a long (say, 18 to 22 second) period, while local storm will generate waves with a shorter (less than 10 second) period. For a given size, the longer period waves will move faster and have more power than shorter period waves. Learn more about wave period.
Storms are associated with large areas of low barometric pressure, with winds blowing in a prevailing direction. Hurricanes are another type of storm, with the winds circulating around the low pressure center. Hurricanes also produce waves, with the most significant wave generation in the direction of the Hurricane’s travel.
As waves move away from their source they spread apart and smooth out into long, even lines. They will also gradually decay in size, so there is such a thing as being too far away from a storm.
Each surf spot generally has an optimum wave size, direction and period that makes it work the best. Many sandy-bottom beach breaks “close out” (break all at once) over a certain size, while reef breaks and point breaks can generally handle larger swells. The coastline orientation and the presence of offshore islands may create wave “shadows” that block swells from a certain direction.
Swells can also “refract” (bend) as they begin to encounter shallow depths. This can be seen at many point breaks as the waves wrap around the point and also where offshore areas have deep submarine canyons (e.g., Blacks).
An interesting feature of swells as they move through the ocean is that the wave energy moves through the water, but water molecules don’t move forward. They move in vertical circles but come back to the same spot.
This all changes when the wave encounters depths shallow enough to allow it to break. Then the wave gets steeper and steeper until the top (crest) of the wave spills (gradually sloping sea floor) or plunges (abruptly shallow sea floor). Examples of spilling waves are at Waikiki or San Onofre, whereas plunging or tubing waves can be found at Pipeline or Teahupoo.
Many other factors affect “surfability” of waves, including tides and local winds. These factors can rapidly improve or degrade surfing conditions, regardless of the size and direction of the swell.
Wave or surf forecasting takes all these factors into account and has progressed rapidly in the last two decades from reliance on weather charts and observations to sophisticated computer models that take into account data from buoys, wind measurements, satellite photos and other data inputs.
The pioneer of surf forecasting is Dr. Walter Munk of Scripps Institution of Oceanography. To learn more about Dr. Munk's groundbreaking studies, watch the 3-part video below titled "Waves Across the Pacific" which summarizes studies conducted in 1963 by Dr. Munk and a team of researchers who tracked waves generated by Antarctic storms as they traveled north and east across the Pacific Ocean past New Zealand, Samoa, Hawaii and finally to Alaska.
Way prior to that, a young Walter Munk was involved in wave predictions for the D-Day invasion at Normandy in World War II.
Also see this slide show Where the Swell Begins by Walter Munk and Cher Pendarvis.
What Causes Waves? (Discovery.com)
Where Do Waves Come From? (Surfline.com)
Oceanography: Ocean Waves (Buzzle.com)
Introduction to Ocean Waves (Rick Salmon, Scripps Institution of Oceanography) Warning: Heavy Math!
Surf Forecasts (Surfline.com)