This paper proposes a Fault Node Recovery and Replacement (FNRR) algorithm for enhancing the lifetime of wireless sensor networks (WSNs) by combining Grade Diffusion and Genetic Algorithms to reduce sensor node replacements. The FNRR algorithm has shown improvements in the number of active nodes, reduction in energy consumption, and decreased costs of replacing sensor nodes in simulations. Overall, the algorithm effectively optimizes the operational efficiency of WSNs while minimizing energy waste.