The concept of the Internet of Things (IoT) consists of various sensing devices that have been subject to the threats that stem from an increased dependence on the technologies of communication. The IoT is the concept of healthcare is the main ingredient in the provision of medical facilities to patients and also facilitates both hospitals and doctors. The system proposed contained different medical devices like the sensors and the applications that are mobile-based or web-based. These communicate by means of the devices connected through the network that helps in monitoring and recording medical information and health data of the patients. The IoT was characterized by distributed topology and limited energy. For this scenario, there is a routing algorithm that is energy-saving and secure playing a major role to ensure IoT performance. The aggregation of security data has a crucial role in reducing the transmission of data and further in prolonging the lifetime of Wireless Sensor Network (WSN). When there was a threat to node security, the nodes had generated different data errors resulting in trouble to the measures of security. Owing to the difference in standards and their communication stacks, the traditional mechanisms to security were dependent on the trust management for functioning. For the purpose of this work, there was a multi-hop routing model used in medical IoT that was proposed. For balancing of consumption of energy and trust, routing from the source to the destination has to be taken into consideration for the appraisal of trust as opposed to the destination peers. At the same time, the consumption of energy has to be one major criterion. There was an Imperialist Competitive Algorithm (ICA) with Harmony Search (HS) that can balance the consumption of energy for the reduction of trust cost. This was based on a socio-politically inspired strategy of optimization. The HS was based on the process of improvisation of musicians. The results of the experiment proved this strategy was better in terms of performance than the other methods.