Internet of Things (IoT) is a superset of Wireless Sensor Networks (WSNs). Due to its distributed nature, it can be employed across different hazardous environments. In WSNs, devices are treated as various resource factors such as computing resources, sources of energy, storage systems, and security resources, necessitating the use of robust dynamic routing protocol. In most significant breakthrough of wireless data transmission the devices are capable of transmitting data with low cost and very minimal power supply in order to enhance network lifetime and optimization of energy consumption in the network. Any intrusion to data and network security might have a real and physical impact on network quality and affects the security to the network will deployed by the sensor nodes for remote monitoring in unauthorized environment. Pertaining to the geographical location, WSNs plays a wide open role in addressing the modern day challenges all around the world. However in WSNs, the selection of the optimal path with reduced energy and providing optimized security still poses a major challenge. To address this challenge, a methodology in this work has been proposed by choosing multiple trust factors to detect the malicious node, thereby electing a efficient cluster head by using Fuzzy temporal rules with Modified Sun Flower Optimization (FMSFO) algorithm. Moreover, the proposed system produces high reliability and security by employing modified Elgamal Digital Signature algorithm for secured data transmission for the nodes of WSNs. The proposed system provides high potentiality against various types of attacks by reducing the packet loss in indentify the malicious node, resulting in a better QoS and enhance the lifetime of the sensor nodes. The proposed protocol is implemented in NS3 simulator by using realistic simulation parameters. The simulation shows that the proposed method is efficient in terms of energy efficiency, throughput, PDR ratio, delay and provides better security when it is compared with the other existing state of art systems.