Hybrid microgrids are presented as a solution to many electrical energetic problems. These microgrids contain some renewable energy sources such as photovoltaic (PV), wind and biomass, or a hybrid of these sources, in addition to storage systems. Using these microgrids in electric power generation has many advantages such as clean energy, stability in supplying power, reduced grid congestion and a new investment field. Despite all these microgrids advantages, they are not widely used due to some economic aspects. These aspects are represented in the net present cost (NPC) and the levelized cost of energy (LCOE). To handle these economic aspects, the proper microgrids configuration according to the quantity, quality and availability of the sustainable source of energy in installing the microgrid as well as the optimal design of the microgrid components should be investigated. The objective of this paper is to design an economic microgrid system for the Yanbu region of Saudi Arabia. This design aims to select the best microgrid configuration while minimizing both NPC and LCOE considering some technical conditions, including loss of power supply probability and availability index. The optimization algorithm used is Giza Pyramids Construction (GPC). To prove the GPC algorithm’s effectiveness in solving the studied optimization problem, artificial electric field and grey wolf optimizer algorithms are used for comparison purposes. The obtained results demonstrate that the best configuration for the selected area is a PV/biomass hybrid microgrid with a minimum NPC and LCOE of $319,219 and $0.208/kWh, respectively.