Off-grid electrification of remote communities using sustainable energy systems (SESs) is a requisite for realizing sustainable development goals. Nonetheless, the capacity planning of the SESs is challenging as it needs to fulfil the fluctuating demand from a long-term perspective, in addition to the intermittency and unpredictable nature of renewable energy sources (RESs). Owing to the nonlinear and non-convex nature of the capacity planning problem, an efficient technique must be employed to achieve a cost-effective system. Existing techniques are, subject to some constraints on the derivability and continuity of the objective function, prone to premature convergence, computationally demanding, follows rigorous procedures to fine-tune the algorithm parameters in different applications, and often do not offer a fair balance during the exploitation and exploration phase of the optimization process. Furthermore, the literature review indicates that researchers often do not implement and examine the energy management scheme (EMS) of a microgrid while computing for the capacity planning problem of microgrids. This paper proposes a rule-based EMS (REMS) optimized by a nature-inspired grasshopper optimization algorithm (GOA) for long-term capacity planning of a grid-independent microgrid incorporating a wind turbine, a photovoltaic, a battery (BT) bank and a diesel generator (Dgen). In which, a rule-based algorithm is used to implement an EMS to prioritize the usage of RES and coordinate the power flow of the proposed microgrid components. Subsequently, an attempt is made to explore and confirm the efficiency of the proposed REMS incorporated with GOA. The ultimate goal of the objective function is to minimize the cost of energy (COE) and the deficiency of power supply probability (DPSP). The performance of the REMS is examined via a long-term simulation study to ascertain the REMS resiliency and to ensure the operating limit of the BT storage is not violated. The result of the GOA is compared with particle swarm optimization (PSO) and a cuckoo search algorithm (CSA). The simulation results indicate that the proposed technique’s superiority is confirmed in terms of convergence to the optimal solution. The simulation results confirm that the proposed REMS has contributed to better adoption of a cleaner energy production system, as the scheme significantly reduces fuel consumption, CO2 emission and COE by 92.4%, 92.3% and 79.8%, respectively as compared to the conventional Dgen. The comparative evaluation of the algorithms shows that REMS-GOA yields a better result as it offers the least COE (objective function), at $0.3656/kW h, as compared to the REMS-CSA at $0.3662/kW h and REMS-PSO at $0.3674/kW h, for the desired DPSP of 0%. Finally, sensitivity analysis is performed to highlight the effect of uncertainties on the system inputs that may arise in the future.