Slope stability analysis has always been a core issue in the field of geotechnical engineering. However, the distribution of soil layers in slopes exhibits natural spatial variability due to factors such as sedimentation, making it impossible to accurately characterize their true distribution using limited borehole data alone, thereby hindering precise evaluation of their stability. A model was constructed using the strength reduction method combined with numerical simulation, employing the Ball-Wall method for modeling, to analyze the critical soil layer thickness for the stability of terraced slopes. Six factors—bulk density, cohesion, internal friction angle, slope angle, slope height, and pore water pressure ratio—were selected as model inputs. A slope stability prediction model based on the improved Northern Eagle Algorithm-optimized Random Forest (INGO RF) was proposed, and the optimized machine learning model was compared and analyzed with other models. The results indicate that the thicker the fully weathered soil layer, the lower the slope stability coefficient. After 5 days of rainfall, the stability coefficients under different soil layer conditions are not significantly different. However, in the absence of rainfall, slopes with thinner fully weathered soil layers are significantly more stable. The optimal INGO RF model achieved an accuracy rate greater than 0.9 on both the training and testing datasets. After comparing the predictive performance of various models, it was found that the INGO RF model outperforms other models, with bulk density being the most sensitive factor influencing slope stability.