It is argued that the glaciers depsosited minerals in the oceans and thereby fertilized them and encouraged algae blooms. Krill and other zooplankton feed on the algae or phytoplankton and were in turn feed upon by the baleen whales. This abundant food source allowed baleen whales to evolve to huge sizes.
The ice ages perhaps had something to do with the extinction of Megalodon. Many whales, particularly the larger ones, thrive in colder water. Sharks, on the other hand, are more limited to warmer water. The Greenland shark and the sleeper sharks do live in very cold water, just above freezing, but as the name sleeper shark suggests they move very slowly and can not chase down a seal let alone a whale. So the colder waters of the ice ages probably provided a larger area where the whales could feed almost completely free from shark predation.
While great white sharks, which currently prey on marine mammals, are limited to tropical and temperate oceans, killer whales do hunt in the arctic and antarctic. The ice ages probably gave the killer whales large areas of the oceans where they were the top predator, free or almost free of competition from Megalodon and predation by Megalodon.
Furthermore, the baleen whales, which may have been Megalodon's main source of food may have disappeared from warmer waters for much of the year. Baleen whales commonly give birth in warmer waters but feed in colder Arctic and Antarctic waters. Perhaps, Megalodon could not survive the disappearance of their main food source for much of the year.
Disease might have been another difficulty that lead to Megaladon's extinction. If the whales and other marine mammals were absent for months then Megaladon may have been looking for other large prey, the other large animals in the sea were sharks, including whale sharks, basking sharks, and great whites. As these animals are sharks, like the Megaladon they would carry shark specific diseases. So for Megaladon the danger of catching a deadly plague would be greater if Megaladon was eating its fellow sharks as opposed to marine mammals.
Finally, communicable diseases make a large population size more important for survial. If a deadly plague infects a large population there is greater probablity that one member of the population will have a mutation that allows it to survive the plague. If it can survive the plague and pass this mutation on the species may survive and enjoy the protection of the mutation. A small population is less likely to have an idividual with the key mutation.
So if the iceage greatly decreased the population of Megaladon, the small remaining population might have been unable to generate the mutations necessary to protect itself from comunicable diseases.
The largest dinosaurs and the largest whales were both preyed upon by their relatives. Other than the relatively recent human whaling industry, the most and perhaps only significant predator of the blue whale is the killer whale, which is a whale, and therefore fairly closely related to the blue whale.
The largest dinosaurs were sauropods which were related to their theropod predators. Both sauropods and theropods were saurischian dinosaurs, commonly called lizard hipped dinosaurs. The other herbivorous dinosaurs were bird hipped dinosaurs, scientifically called ornithischian dinosaurs. So the largest herbivorous dinosaurs were more closely related to the predatory dinosaurs that preyed on them.
The large predatory dinosaurs that preyed on the sauropods particularly in the Jurassic would have been particularly close to their sauropod prey because both the large predatory theropods and the larger herbivore sauropods would have been relatively rare compared to smaller animals and have longer life cycles than smaller animals.
The number of individuals living at any one moment in time is also important, because the more individual animals the more opportunities for mutations, including beneficial mutations. So two groups of small animals will tend to accumulate useful mutations and evolve away from one another more rapidly than two groups of large animals.
The case of deer in North America also illustrates the issue. The Virginia white-tailed deer carries several diseases that do not kill it, most famously a brain worm. But these diseases are deadly for the larger deer, for example, elk and moose. (Note to Europeans, what we Americans call moose are what you call elk, and what we call elk are red deer, or very closely related to red deer.) As the white-tailed deer's range expands the range of the larger deer retreats. For the most part the larger deer are extinct within the range of the white-tailed deer.
So it is not safe for predators, particularly large predators to eat their close relatives because it is likely make the predator sick, particularly if they do not thoroughly cook their food, which most species other than humans are very lax about. Avoiding cannibalism and near cannibalism is frequently a good survival strategy.
So it maybe more than coincidence that the largest animals have predators that are close relatives. This may reduce the pressure of predation.
Thus the extinction of megalodon, a predator that was not closely related to whales, may have been very important to evolution of very large whales.