In mining projects, all uncertainties associated with a project must be considered to determine the feasibility study. Grade uncertainty is one of the major components of technical uncertainty that affects the variability of the project. Geostatistical simulation, as a reliable approach, is the most widely used method to quantify risk analysis to overcome the drawbacks of the estimation methods used for an entire ore body. In this work, all the algorithms developed by numerous researchers for optimization of the underground stope layout are reviewed. After that, a computer program called stope layout optimizer 3D is developed based on a previously proposed heuristic algorithm in order to incorporate the influence of grade variability in the final stope layout. Utilizing the sequential gaussian conditional simulation, 50 simulations and a kriging model are constructed for an underground copper vein deposit situated in the southwest of Iran, and the final stope layout is carried out separately. It can be observed that geostatistical simulation can effectively cope with the weakness of the kriging model. The final results obtained show that the frequency of economic value for all realizations varies between 6.7 M$ and 30.7 M$. This range of variation helps designers to make a better and lower risk decision under different conditions.