As has already been said, there is no connection whatsoever between cannon-balls piled up on old sailing-ships and the phrase �cold enough to freeze the balls off a brass monkey'.
For a start, given the way ships rolled, pitched and yawed in heavy seas, they would not have stayed in any kind of vertical pile for long, whatever the weather. In fact, they were invariably kept in what were called �shot garlands'...ie planks with appropriately-sized holes. There is no historical record of the word, �monkey', ever having been used to mean a brass ring either.
The plain truth is that �balls' here refer to �testicles'. An early connection between monkeys and weather appears in a Herman Melville novel in which he wrote: "It was �ot enough to melt the nose h'off a brass monkey." Obviously, hot weather was as significant to the poor monkey as cold! Another writer referred to cold weather, saying: "It would freeze the tail off of a brass monkey." Both of these quotes - amongst others relating hair, ears and other simian body-parts to the weather - come from the mid-19th century. It is not until 1937 that the �balls' version was recorded.
There are, therefore, several historical connections behind the phrase, but not one of them has anything to do with cannon-balls!