Clearly it needs to be close to the heart to receive a copious flow of oxygenated blood. Putting the brain too far away from the heart would require some large arteries & veins of unwieldy length. Just something else to break.
My brain’s current location in my skull places it in close proximity all five of my important sensory organs (as long as we count the sense of touch as being in the brain stem). I suppose it could be located inside the chest cavity, but that creates a pinchpoint in the neck where the senses could potentially be cut off (not literally) from the brain if nerves in the neck are damaged. If there ever were any living animals that had brains located away from their sensory organs, they were probably not able to compete with those who had less complicated nervous systems.
Not sure if this is what you are looking for, but jellyfish and starfish have “neural nets” that are located throughout their bodies. These aren’t brains in the truest since of the word, but the organs perform the same tasks as a brain (on a very simple scale of course).
Basically, early organisms had completely noncentralized nervous systems. As nervous systems got more complex centralization made more evolutionary sense, and having the point of centralization nearest the high-bandwith sensory organs was the biologically cheapest way to do it.
In clams (and many other invertebrates), instead of a single brain there are multiple ganglions, each handling various local processing needs. Of course, a clam hasn’t got a head or much in the way of sensory organs.
In every creature with sensory organs clustered in the head, the nerve ganglion which processes the sensory data is right there in the head too. It just makes evolutionary sense. This doesn’t mean that all neural processing system is in the head - in insects, the head-ganglion handles the sensory organs, while ganglions further down the body handle walking, digestion, mating, ect. This is why insects will keep walking around even after you cut their heads off.
Even mammles have distributed processing to some degree - your spinal cord does localized processing for reflexes, and can command muscle movement on its own in response to stimulus without consulting the brain first.
dinosaurs had what amounted to a very large neural conglomeration or “brain” at the base of their tails.
They were so large that a single brain up front didn’t do. They would have been uncoordinated if they relied on it alone because of the time it took nerve impulses to travel.