Every day, WSNs (Wireless Sensor Networks) based healthcare systems is witnessing improvement in providing advice to the health condition and living habits of people. Healthcare applications based on WSNs face crucial problems of security and are vulnerable to assaults. In this study, a privacy-preserving method using the multipath routing and principles of secret keys are suggested for healthcare applications based on WSNs. Multiple paths to the sink will be computed using ECSO (Enhanced Cuckoo Search Optimization). The proposed algorithm utilizes distance and also the traffic rate of paths in the form of a parameter for discovering the optimum paths utilizing ECSO. Among these chosen paths, just one ideal path is chosen based on node energy using BO (Butterfly Optimization) that helps in decreasing the energy demands of the network. Encrypted data will be sent to the sink using the selected path. It is found from the results that the secret key merged with multipath routing is helpful in achieving security of privacy in healthcare systems based on WSNs. The results of simulation performance metrics are throughput, End to End delay, PDR, Energy Consumption, encryption time.