Gestational diabetes mellitus (GDM) is one of the pregnancy complications that endangers both mothers and babies. GDM is usually diagnosed at 22–26 weeks of gestation. However, early prediction is preferable because it may decrease the risk. The continuous monitoring of the mother’s vital signs helps in predicting any deterioration during pregnancy. The originality of this research is to provide a comprehensive framework for pregnancy women monitoring. The proposed Data Replacement and Prediction Framework consists of three layers, which are: (i) Internet of things (IoT) Layer, (ii) Fog Layer, and (iii) Cloud Layer. The first layer used IoT sensors to aggregate vital signs from pregnancies using invasive and non-invasive sensors. The vital signs are then transmitted to fog nodes to be processed and finally stored in the cloud layer. The main contribution in this research is located in the fog layer producing the GDM module to implement two influential tasks which are as follows: (i) Data Finding Methodology (DFM), and (ii) Explainable Prediction Algorithm (EPM) using DNN. First, the DFM is used to replace the unused data to free up the cache space for new incoming data items. The cache replacement is very important in the case of the healthcare system as the incoming vital signs are frequent and must be replaced continuously. Second, the EPM is used to predict the occurrence of GDM in the second trimester of the pregnancy. To evaluate our model, we extracted data from 16,354 pregnant women from the medical information mart for intensive care (MIMIC III) benchmark dataset. For each woman, vital signs, demographic data, and laboratory tests were aggregated. The results of the prediction model are superior to the state-of-the-art (ACC = 0.957, AUC = 0.942). Regarding explainability, we used Shapley additive explanation (SHAP) framework to provide local and global explanations for the developed models. Overall, the proposed framework is medically intuitive and allows the early prediction of GDM with a cost-effective solution.