Locating and Sizing of Distributed Generation (DG) is an important research topic in the development of microgrids. First, this paper models the uncertainty of its two main Distributed Generation, wind power generation and photovoltaic power generation. Then, considering the economic benefits and technical requirements, three important indicators including investment benefit, network loss improvement and static voltage stability improvement are selected to optimize locating and sizing of DG, and the particle swarm optimization algorithm with inertia weight is used to solve the problem. Finally, the simulation analysis of the IEEE-37 node test feeder shows that the method can effectively improve the voltage level of the system, reduce the active power loss, and improve the static voltage stability of the system. It has certain practical value in the distribution network planning.