This study explores the integration of renewable energy sources, namely, solar and wind, focusing on strategies to optimize their deployment into the electrical grid, and increasing the resiliency of the grid. Using four-year comprehensive data from Spain, including energy consumption, generation, pricing, and the condition of the weather, advanced statistical analysis, regression models, and optimization methods have been employed. Based on the results, it is clear that solar energy is seasonal, and wind energy is variable, with the weather playing a considerable role in the energy output. The optimization analysis showed that when the renewable capacity was increased to include 30 MW of solar and 120 MW of wind, the energy demand would be met at a significantly lower total system cost of $12.60 per unit. The costs related to operation and emissions would also decrease notably. However, with the regression models giving modest values of R² equal to 0.19 for solar and R² equal to 0.21 for wind, the extent of these developments and prediction can be fairly modest. Still, these results provide a strong backbone for the prediction of energy generation and show that modernization of the grid and adaptive management are of crucial importance. The results of the study could provide a guideline for policymakers and energy managers on how these goals can be achieved.