It depends on the species of shark. This sort of question is often based on the assumption that sharks must swim constantly in order to pass water over their gills and oxygenate their blood. This is definitely more the exception than the rule. All sharks evolved from an ancestral species that actively pumped water over its gills (as did all bony fish). As the sharks (or Elasmobranchs, to use the scientific term) diversified, some became open-water (pelagic) hunters whilst others adopted a more sedentary lifestyle.
A few of these open-water pelagic species (such as the mako, great white and Zambezi shark) have lost the ability to pump water over their gills and so must constantly swim forwards with their mouths open to pass oxygenating water over their gills. This method of ventilation is known as “ram ventilation” (or ram breathing) and is only found in around 20 of the almost 400 known shark species.
If the shark is an obligate ram ventilator and you prevent it from swimming, it will start to suffocate as the speed of the water passing over its gills decreases and there’s a drop in the level of oxygen reaching the cells of its body.
But constant motion is not a necessity for all sharks. And if you’re ever discussing this with someone who disagrees, make sure you mention the curious-looking angel shark. This sedentary bottom feeder buries itself in the sand and waits, motionless, for an unfortunate fish to pass by before throwing its cavernous mouth open as wide as it can and allowing the resulting vacuum (or “pressure drop”, to be more precise) to suck the prey down into its stomach. An animal that must move continuously in order to respire could never lead this sort of life! Watch the following video (from 33 seconds in) for a brilliant demonstration of this very odd hunting style.