Ensuring accurate forecasts of Global Horizontal Irradiance (GHI) stands as a pivotal aspect in optimizing the efficient utilization of solar energy resources. Machine learning techniques offer promising prospects for predicting global horizontal irradiance. However, within the realm of machine learning,the importance of feature selection cannot be overestimated, as it is crucial in determining performance and reliability of predictive models. To address this, a comprehensive machine learning algorithm has been developed, leveraging advanced feature importance techniques to forecast GHI data with precision. The proposed models draw upon historical data encompassing solar irradiance characteristics and environmental variables within the Ouarzazate region, Morocco, spanning from 1st January 2018, to 31 December 2018, with readings taken at 60-minute intervals. The findings underscore the profound impact of feature selection on enhancing the predictive capabilities of machine learning models for GHI forecasting. By identifying and prioritizing the most informative features, the models exhibit significantly enhanced accuracy metrics, thereby bolstering the reliability, efficiency, and practical applicability of GHI forecasts. This advancement not only holds promise for optimizing solar energy utilization but also contributes to the broader discourse on leveraging machine learning for renewable energy forecasting and sustainability initiatives.