Swimming while pregnant is wonderful exercise.
It is low impact, has both strength and cardiovascular benefits, and can safely be done throughout pregnancy.
Diving is another issue.
Simply stated, pregnant women should not dive. It poses health risks to themselves and their fetus.
Pregnant women have increased amounts of body fat and 3rd-space fluid retention, each of which tends to trap nitrogen and other gasses due to poor circulation through those areas. This predisposes them to decompression sickness and air embolism.
While fetuses do not form gas bubbles more easily than women, even a few bubbles are likely to be very dangerous to the fetus because of fetal circulation. In adults, bubbles tend to be filtered by the pulmonary circulation through the lungs, but in fetuses, there is a bypass of the lung circulation through the foramen ovale and ductus arteriosus. This means that bubbles will not be filtered but may instead go directly to the brain or coronary vessels, possibly causing stroke or death.
There is also evidence that diving may produce birth defects, including limb reductions, cardiac malformations, and other problems, although this area has not been carefully researched.