Weirdly -- although the existence of one doesn't depend, really, on the existence of the other -- the refrigerator and the milk carton developed in parallel. The first refrigerators were tested in the 1910s. Meanwhile, the inventor of the milk carton (warning: this title is disputed by about a million people) took out his patent in 1915.
His name was John Van Wormer and his milk carton was basically the same as the one we use today. It's called a gable-top, in reference to the innovation of the spout temporarily glued into a ridge and unleashed by that weird pinching-pulling motion that I referred to earlier. The gable-top makes a pretty efficient use of materials, which also means you can produce it quickly. (The milk carton does not need a cap, you might note.) Van Wormer produced his original milk cartons in paperboard. And so they are today, but generally with a slick polyethylene coating, so they don't become vaguely wet to the touch once the milk soaks through.
As with the refrigerator, it took the milk carton two or three decades to catch on. People had become attached to their glass milk bottles.
Emotions be damned, here is the thing. Glass is heavy. The weight of the bottle makes up a total of a third of the weight of a unit of milk packaged in glass (yes, sometimes they still are!). Hey, and you know what? Hauling giant bricks of ice around to put into an icebox is a huge drag!