Cloud computing is a potential platform transforming the health sector by allowing clinicians to monitor patients in real-time using sensor technologies. However, the users tend to transmit sensitive and classified medical data back and forth to cloud service providers for centralized processing and storage. This presents opportunities for hackers to steal data, intercept data in transit, and deprive patients and healthcare providers of private information. Consequently, Security and privacy are the primary concerns that must be addressed for the healthcare organization to trust and adopt the cloud computing platform. We present data sanitization and restoration processes to generate the keys from the acquired data and develop a multi-objective function for the hiding ratio, degree of modification, and information preservation ratio. We then employed the Bee-Foraging Learning-based Particle Swarm Optimization (BFL-PSO) algorithm to acquire the optimal key while transferring healthcare data into the cloud to ensure high Security. The experiment is carried out on the UHDDS dataset. The performance is assessed in terms of Security, delay time, encryption time, error rate, and convergence speed, with the results contrasted to state-of-the-art works. The performance study demonstrates that the suggested algorithm has higher Security than cutting-edge security algorithms.