In ancient times a photographer would load his camera, remove the lens cap, time the exposure and put the lens cap back on.
As photographic materials became more sensitive to light, exposures became shorter and shutter techniques more sophisiticated. Over time two kinds of shutter proved to be the most practical and are still used today.
Between the lens or leaf shutters operate like an iris that fully closes. To make an exposure the shutter blades move apart for a brief moment and then close again. Leaf shutters synchronize with flashlight at all speeds.
Focal plane shutters comprise two opaque curtains. The first curtain blocks the light path. During exposure it moves out of the way to be followed by a second curtain which covers the exposed film or CCD. Exposure is controlled by adjusting the timing between the two curtains. Maximum flash synchronization speed is determined by the moment the shutter curtains are completely open. This would typically be 1/125 or 1/60. At faster shutter speeds, the curtains form a moving slit and flashlight will only expose that part of the film or CCD not covered by the shutter curtains.
Although digicams often use mechanical shutters, some models have a CCD shutter. Here exposure time is determined by limiting the sampling time of the sensor. It is completely electronic with no mechanical movement. Control is precise and reliable.