Microgrids have been widely used due to their advantages, such as flexibility and cleanliness. This study adopts the hierarchical control method for microgrids containing multiple energy sources, i.e., photovoltaic (PV), wind, diesel, and storage, and carries out multi-objective optimization in the tertiary control, i.e., optimizing the economic cost, environmental cost, and the degree of energy utilization of microgrids. As the traditional multi-objective particle swarm algorithm is prone to local convergence, this study introduces variable inertia weight and learning factors to obtain a modified particle swarm algorithm, which is more advantageous in multi-objective optimization. Compared to the traditional particle swarm algorithm, the modified particle swarm algorithm increased the photovoltaic absorbed rate from 0.7724 to 0.8683 and the wind energy absorbed rate from 0.6064 to 0.7158 in one day, which resulted in an increase in energy utilization by 14.89%, and a reduction in financial environmental costs from RMB 135,870 to RMB 132,230. The simulation of the optimization effect of the conventional particle swarm algorithm and the modified particle swarm algorithm on the microgrid were carried out, respectively, in MATLAB, which verifies the advantage of the modified particle swarm algorithm on the optimization of microgrids. Then, the optimization results, i.e., the data of the power scheduling process of the four power sources, were made into a table and imported into the microgrid model in Simulink. The simulation results indicated that the microgrid was able to output stable voltage, current, and frequency. Finally, the changes in microgrids affected by the external environment were further investigated from the aspects of the market environment and natural environment. Moreover, we verified the presence of a contradiction between the optimization of the microgrid economy and environmental protection. Thus, microgrids need to adjust their optimization focus according to the natural conditions in which they are located.