In a smart grid (SG) system with load uncertainties and the integration of variable solar and wind energies, an effective frequency control strategy is necessary for generation and load balancing. Cyberattacks are emerging threats, and SG systems are typical cyber-attack targets. This work suggests an improved gorilla troops optimizer (iGTO)-based fuzzy PD-(1+PI) (FPD-(1+PI)) structure for the frequency control of an SG system. The SG contains a diesel engine generator (DEG), renewable sources like wind turbine generators(WTGs), solar photovoltaic (PV), and storage elements such as flywheel energy storage systems (FESSs) and battery energy storage systems (BESSs) in conjunction with electric vehicles (EVs). Initially, the dominance of the projected iGTO over the gorilla troops optimizer (GTO) and some recently suggested optimization algorithms are demonstrated by considering benchmark test functions. In the next step, a traditional PID controller is used, and the efficacy of the GTO method is compared with that of the GTO, particle swarm optimization (PSO), and genetic algorithm (GA) methods. In the next stage, the superiority of the proposed FPD-(1+PI) structure over fuzzy PID (FPID) and PID structures is demonstrated under various symmetry operating conditions as well as under different cyberattacks, leading to a denial of service (DoS) and delay in signal transmission.