The increasing demand for energy, coupled with concerns about the environment and finite resources, has made the use of renewable energy sources (RESs) crucial. Although wind and solar energy are one of the most promising sources of renewable energy, their random and uncertain nature poses a challenge for energy management systems. The integration of RESs into distribution networks (DNs) is a challenging task that requires optimizing DN planning. This involves incorporating distributed generation (DG) systems such as wind turbines (WTs) and photovoltaics (PVs) into the distribution networks, which can be optimized to reduce costs, additionally, the resulting configuration can noticeably improve stability by enhancing the voltage stability index and reducing voltage deviation. In this paper, a novel Modified Reptile Search Algorithm (MRSA) is proposed for the optimal planning problem (OPP) of the DN under uncertainties such as solar irradiance, wind speed, load, temperature, and energy prices. The proposed MRSA is based on two strategies, including the fitness-distance balance method and the Levy flight motion, to boost the searching ability of the standard RSA and avoid local optima. The suggested MRSA algorithm has been evaluated on typical benchmark functions and a real 112-bus Algerian distribution network.