As the future direction of power development, microgrids are particularly important for rational and efficient energy management. This article establishes an optimization model with multiple uncertainties as parameters for the microgrid energy system, with the objective function of minimizing operating costs. Then, an improved harmony algorithm was used to solve for the optimal solution of the model parameters. Finally, a microgrid system consisting of wind and thermal power units established in a certain area of Hebei Province was used for solution analysis. After experimental verification, the proposed method in this paper achieved significant improvements in both operational cost reduction and microgrid efficiency.