When using flash, shooting at the sync speed ensures that you're using your flash most efficiently. Here's why.
Aperture affects both ambient and flash exposure. The larger the aperture, the more light enters the sensor (from both flash and ambient). The most output from your flash will result from the widest aperture. The catch though is that a wider aperture will also increase the ambient exposure, possibly to the point of overexposure.
Enter shutter speed. Shutter speed affects ambient but not flash exposure (up to a limit, as discussed below). The duration of a burst of flash is so brief that whether the shutter travels quickly or slowly, all of the flash burst reaches the sensor. That is, of course, assuming the entire sensor is exposed.
Indeed, the entire sensor is fully exposed at typical shutter speeds. At a high shutter speed, however, the rear curtain starts to close even before the front curtain has traveled completely, therefore the sensor is never fully exposed at any given time. When the flash is fired at these very high speeds, the part that is covered by the rear curtain will not be exposed to flash, leading to uneven exposure which is visible as a dark bar across the bottom or top of the image. The highest shutter speed where the entire sensor is fully exposed is the camera's sync speed. Typical sync speeds are 1/200 or 1/250, but sometimes as slow as 1/125 and as high as 1/500. (Trivia: medium format cameras with leaf shutter lenses can sync at all speeds, and point-and-shoots can sync at any speed because they don't have mechanical shutters :-D ) By default, cameras usually prevent the use of shutter speeds faster than the sync speed when the flash is being used.
Going back to the discussion, higher shutter speeds will nonetheless reduce ambient exposure. We use this to our advantage using the reciprocal relationship between shutter speed and aperture for any given exposure. Let's say it's a bright, sunny day, and the correct exposure is f/16 at 1/125 at 100 ISO. Under the reciprocity principle, you can get the same exposure with any of these combinations:
f/11 at 1/250 at 100 ISO
f/16 at 1/125 at 100 ISO
f/22 at 1/60 at 100 ISO
Of the three combinations above, the one that will require the least power from the flash is the one with the widest aperture, i.e., f/11 at 1/250 at 100 ISO.
Does that mean we should just use aperture priority and always choose the widest aperture to get the most from our flash? Not necessarily. If conditions are bright and aperture is wide, then the shutter speed can be pretty high -- higher than the sync speed. In the example above, suppose we had a lens that can go as wide as f/2.8. If we change aperture to f/2.8, the shutter speed for the same exposure would be 1/4000, which is way faster than the sync speed.
What about high speed sync mode? External flashes can fire at shutter speeds higher than the natural sync speed at the expense of output by firing many small flash bursts (instead of a single flash burst) while the rear curtain travels across the sensor. With HSS, however, the flash loses slightly more than 2 stops of output. In other words, it becomes more than 4x weaker. In other words, its range drops to slightly less than half. You get the idea.
In summary, if you want to maximize your flash while minimizing your ambient, shoot at the sync speed.