There is a surge in the total energy demand of the world due to the increase in the world’s population and the ever-increasing human dependence on technology. Conventional non-renewable energy sources still contribute a larger amount to the total energy production. Due to their greenhouse gas emissions and environmental pollution, the substitution of these sources with renewable energy sources (RES) is desired. However, RES, such as wind energy, are uncertain, intermittent, and unpredictable. Hence, there is a need to optimize their usage when they are available. This can be carried out through a flexible operation of a microgrid system with the power grid to gradually reduce the contribution of the conventional sources in the power system using energy storage systems (ESS). To integrate the RES in a cost-effective approach, the ESS must be optimally sized and operated within its safe limitations. This study, therefore, presents a flexible method for the optimal sizing and operation of battery ESS (BESS) in a wind-penetrated microgrid system using the butterfly optimization (BO) algorithm. The BO algorithm was utilized for its simple and fast implementation and for its ability to obtain global optimization parameters. In the formulation of the optimization problem, the study considers the depth of discharge and life-cycle of the BESS. Simulation results for three different scenarios were studied, analyzed, and compared. The resulting optimized BESS connected scenario yielded the most cost-effective strategy among all scenarios considered.