In recent years, the financial and energy crises have made the economical and safe operation of distribution microgrids one of the main challenges for operators. In this regard, the optimal distribution of the microgrid, considering the favorable indicators of Generation and consumption, significantly improves the quality of the development and economic operation of electricity grids. On the other hand, distribution microgrids have many problems and complications due to the presence of DG sources and the uncertainties caused by them in Generation and consumption, such as the inability to solve optimal load distribution using common and common calculation methods. Therefore, grid technical indicators such as voltage deviation and losses in solving load distribution add to the complexity of related issues. To solve the challenges raised in the distribution microgrid, this paper proposes an optimal load distribution model that models the uncertainties in the distribution microgrids using the Monte Carlo method. Using meta-heuristic algorithms, the optimal Generation function by modeling grid security constraints such as voltage deviation, losses, and a load limit of the system should be in economic operation mode, and then the power distribution equations should be solved. The battery can supply 1 kW of active power to the system at a cost of 1 unit/kW during the high cost period if it absorbs 1 kW of active power at a cost of 0.92 units/kW during the low cost period. Additionally, the active and reactive power losses have been decreased to 0.3kW and 0.2kW, respectively, by utilizing the suggested methodology. The simulation results show that the proposed method performs satisfactorily and that the modeling is simulated in MATLAB software.