In Wireless Sensor Networks, numerous machine-learning algorithms are used in the packet routing strategy. The recommended routing approach is implemented using adaptive reinforcement learning and a spider monkey optimization algorithm. Data packets are sent over the network via optimum route establishment—the above attempts to save energy by changing the Q-value at each instance. Technology enables adaptive mechanisms to demonstrate intelligent behavior in complex and dynamic situations such as Wireless Sensor Networks (WSN). Recently, new routing methods for WSNs have been devised in response to such a notion. Due to user interference and overall network performance, the numerous routing pathways cause frequent channel-switching occurrences. The spider monkey optimization method obtains routing metrics such as bandwidth, end-to-end latency, throughput, overhead, and packet delivery ratio. Compared to other machine learning algorithms, such as RLBR, the performance of WSN is improved and obtained better performance results.