This post is about how a lake freezes, but it should be more or less the same for how an insulated container freezes in a freezer. The information is from the excellent book, Ice: The Nature, the History, and the Uses of an Astonishing Substance by Mariana Gosnell.
As temperatures lower, the water in a lake "turns over." The top layer of water is heated by the sun during the day and is therefore warmer and lighter than the layers below it. At night without the sun, the cool air above the lake cools the top layer of water, which makes it denser than the layers beneath it. The top layer of water sinks. The new top layer gets colder until it too sinks. This is repeated until the top part of the water column reaches the same cool temperature.
This temperature is not the freezing temperature of 32 degrees Fahrenheit, but 39 degrees. That's the temperature at which water is at its densest and heaviest. This also means that water contracts at this temperature and takes up the least space.
Latent Heat of Fusion
After the lake has reached 39 degrees throughout the top part of the water column, as the cold air above it sinks to a lower temperature than the water, the water cools off to below 39 degrees. Now, however, the water getting colder makes it lighter than the 39 degree water below it, so the water no longer turns over. It stays on top and continues to cool until freezing.
For water at 32 degrees to convert to ice at 32 degrees, a lot of energy must be given up. Normally it takes 1 calorie of energy to change the temperature of 1 gram of water by 1 degree Celsius, but when water is changing phases to ice, it must give up nearly nearly 80 calories of energy to change phase without changing temperature at all.
Sometimes as the water is giving up the 'latent heat' to change phases, little wisps of fog are visible above the water's surface.
In most cases, ice crystals form at a nucleation point: a bit of something around which an ice crystal builds. This is often an impurity in the water, and in a lake can be dirt, snow, or even rain.
The ice crystals that form initially can be in weird shapes across the surface of the water rather than an even grid pattern.
Lakes tend to freeze from the outside-in, as nucleation points are on the shore and the water isn't as deep there. I assume that ice cube trays would also freeze from the outside-in as the nucleation point would be spots along the side of the tray.
Clear ice on a lake is an indication that it froze slowly. As ice crystals form, the crystal lattice is is tight and there isn't room for impurities to fit inside it. (Ironic since impurities are usually needed to start the crystallization process.) Thus slow-freezing ice rejects impurities including air, minerals, and salts, and pushes them out of the way.
This is why the last part of the ice to freeze is where any trapped air and impurities are. Most ice cubes are cloudy in the middle because the water is freezing on all four sides of the container; outside-in. On a lake or by using an insulated cooler in the freezer at home, the only coldness is coming from the top.
In a lake the water doesn't freeze all the way to the bottom so lake ice is very clear - the impurities and air are beneath it still in the liquid. In a cooler in the freezer, the cloudy part of the ice is only on the bottom - the last place that freezes.
After the ice crystals have formed on the surface, they eventually start growing down, thickening the ice. But as the ice thickens, the water beneath it turns into ice at a slower pace. This is because ice is a poor conductor of heat, so the thicker the ice, the further the distance the latent heat of freezing has to get to the cold air above the pond. In other words, the rate of freezing slows the thicker the ice.
When sea ice freezes, most of the impurities - the salt- is pushed out of the freezing ice towards the bottom of the ocean. But about one-fifth of of the salt stays in pockets between crystals, in little capillaries.