To be “nuts” is to be crazy. The head, often referred to as one’s nut, is the locus of sanity. If it if cracked — if one has become cracked — then one has turned into a “nutter.” Mental institutions are known as “nuthouses” accordingly. To be described as a “fruitcake” means to be nutty — crazy. Fruitcakes traditionally have lots of nuts in them, hence the term.
Although fruitcakes are as old as time, using them to refer to crazy people only dates back to 1952.
Budget Saving Meals Cookbook, Ideals Publishing, 1980