By moving the crew's weight to windward, the moment of that force around the boat's center of buoyancy is increased.
The heavy keel on larger keelboats means that it is rare to capsize them due to wind alone, but keelboat racers will still hike to prevent unnecessary heeling, or leaning sideways to leeward, because the more vertical in the water the keel is, the more effective it is at keeping the boat moving in a forward direction and preventing it from drifting to leeward, slowing the boat due to drag, and potentially increasing the distance the boat must sail when beating.
Improper heel creates a tendency for the boat to turn off course, necessitating a correction with the rudder, which also increases drag.
Some sailors wear special shorts fitted with pads or stiff battens to help them hike more effectively and without tiring.
Some dinghies and catamarans, such as the 505, 420, International 14, or Hobie 16, have a trapeze to allow the crew to increase their righting moment on the boat.