The Internet of Things (IoT) has impacted various aspects of life, but its profound effects on the health sector are particularly striking because of its cutting-edge nature. Mobile computing characteristics enable IoT to play a more important role when used with mobile computing. A significant part of the benefits of IoT in healthcare can be attributed to mobile health, which is greatly enhanced by mobile computing. Wearables transmit large amounts of data to IoT devices through sensors, actuators, and transceivers. Threats, attacks, and vulnerabilities abound for data on the Internet of Things. Therefore, addressing IoT-related security, privacy, and vulnerability issues call for a robust security solution. This paper proposes a secure and scalable healthcare data transmission framework in IoT based on an optimized routing protocol. Initially, the health data is collected from various IoT devices like wearable devices and sensors. The raw data is preprocessed via data cleaning and data reduction techniques. K-nearest neighbor (KNN) imputation is performed and principal component analysis (PCA) is employed for dimension reduction of the data. Utilizing modified local binary patterns (MLBP), the features are extracted from the preprocessed data. By combining the fuzzy dynamic trust-based RPL algorithm with the butter ant optimization (BAO) algorithm for low-power and lossy networks, the proposed fuzzy dynamic trust-based RPL (FDT-RPL) protocol improves the overall security of data transmission. The algorithm has been implemented for a smart healthcare system, and the performance is analyzed by comparing it with traditional approaches. The proposed routing protocol provided a secure and scalable healthcare data transmission.