While designing the inverter, the total harmonic distortion (THD) in the output is a major concern to decide its performance. In order to calculate the total harmonic distortion (THD) of a symmetric modular multilevel inverter (MMI) with switched capacitors, a Harris hawk optimization (HHO) was used in this study. Utilizing symmetric and identical DC sources, the suggested modular multilevel inverter is designed. The suggested topology may be expanded up to many levels and utilizes fewer switches to provide 9 levels of output than conventi1al cascaded H-bridge multilevel inverters. Using a low-frequency switching control approach known as selective harmonic elimination pulse width modulation, the switches are less stressed and the inverter output's THD profile is improved. Additionally, the switching angles of the MMI have been optimized by solving the non-linear equations of the SHEPWM using the Harris Hawk Optimizer. Ant colony optimization (ACO) and particle swarm optimization (PSO), two alternative optimizers, were compared in terms of the THD of the output. This comparison shows that the HHO delivers a lower THD than other optimization techniques approximately near to 5%, as per the IEEE-519 standard, and is thus more highly advised. Finally, a hardware configuration for the suggested inverter is implemented to confirm the simulation findings.