In wireless sensor networks, the implementation of clustering and routing protocols has been crucial in prolonging the network’s operational duration by conserving energy. However, the challenge persists in efficiently optimizing energy usage to maximize the network’s longevity. This paper presents CHHFO, a new protocol that combines a fuzzy logic system with the collaborative Harris Hawks optimization algorithm to enhance the lifetime of networks. The fuzzy logic system utilizes descriptors like remaining energy, distance from the base station, and the number of neighboring nodes to designate each cluster head and establish optimal clusters, thereby alleviating potential hot spots. Moreover, the Collaborative Harris Hawks Optimization algorithm employs an inventive coding mechanism to choose the optimal relay cluster head for data transmission. According to the results, the network throughput, HHOCFR is 8.76%, 11.73%, 8.64% higher than HHO-UCRA, IHHO-F, and EFCR. In addition, he energy consumption of HHOCFR is lower than HHO-UCRA, IHHO-F, and EFCR by 0.88%, 39.79%, 34.25%, respectively.