The IoT has applications in many areas such as manufacturing, healthcare, and agriculture, to name a few. Recently, wearable devices have become popular with wide applications in the health monitoring system which has stimulated the growth of the Internet of Medical Things (IoMT). The IoMT has an important role to play in reducing the mortality rate by the early detection of disease. The prediction of heart disease is a key issue in the analysis of clinical dataset. The aim of the proposed investigation is to identify the key characteristics of heart disease prediction using machine learning techniques. Many studies have focused on heart disease diagnosis, but the accuracy of the findings is low. Therefore, to improve prediction accuracy, an IoMT framework for the diagnosis of heart disease using modified salp swarm optimization (MSSO) and an adaptive neuro-fuzzy inference system (ANFIS) is proposed. The proposed MSSO-ANFIS improves the search capability using the Levy flight algorithm. The regular learning process in ANFIS is dependent on gradient-based learning and has a tendency to become trapped in local minima. The learning parameters are optimized utilizing MSSO to provide better results for ANFIS. The following information is taken from medical records to predict the risk of heart disease: blood pressure (BP), age, sex, chest pain, cholesterol, blood sugar, etc. The heart condition is identified by classifying the received sensor data using MSSO-ANFIS. A simulation and analysis is conducted to show that MSSA-ANFIS works well in relation to disease prediction. The results of the simulation demonstrate that the MSSO-ANFIS prediction model achieves better accuracy than the other approaches. The proposed MSSO-ANFIS prediction model obtains an accuracy of 99.45 with a precision of 96.54, which is higher than the other approaches.