There have been several ideas about why sperm whales have spermaceti, but scientists generally seem to think it helps with echolocation. Sperm whales hunt squid and other prey in the deep, dark part of the ocean, where they cannot hunt by sight, so they hunt with sound. Their heads send out powerful acoustic waves that bounce off prey or other surroundings and return to the whale, first passing through a special acoustic fat pad at the back of the jaw and then up to the ear. From there, the brain can work out where things are.
For this to work, the sound must be very loud and focused in one direction, and the whale's giant nose plays the key role. The sound starts in the right nostril, which has evolved in an unusual way: instead of leading out of the head like the left nostril, it ends in a percussion chamber. Inside is a structure called the phonic lips, or 'monkey lips,' which slam open and shut when air is forced through them, making a loud clicking noise. The sound then travels back through the spermaceti organ, which likely focuses it, bounces off an air sack near the skull, and passes through another organ called the junk, filled with fatty, lens-like tissue.
The resulting sound is, in Geary's words, 'the loudest sound in the animal kingdom: up to 230 decibels.' Other whales and dolphins can echolocate too, but their setup is usually different and they do not use this back-and-forth reflection. Thanks to this arrangement, sperm whales can operate sonar in very deep, high-pressure water and have longer detection ranges than other whales. Scientists have also proposed that spermaceti could help with buoyancy, or act as a built-in cushion when whales ram each other or their foes. Geary suggests it may be all three, but says the more important question for the story is how humans used it.