The grid integration of renewable energy sources necessitates using energy storage systems (ESSs) to provide more flexibility and controllability. This paper proposes a frequency stability-constrained battery energy storage system (BESS) sizing model for microgrids formulated as a mixed-integer linear programming (MILP) problem and decomposed using Benders decomposition. The optimal size of BESS is determined as a trade-off between minimizing the operating costs or maximizing the benefits and the high investment costs of BESS. Both the grid-connected and stand-alone operating modes are modeled for the microgrid along with the corresponding generation contingencies. The microgrid scheduling optimization model is built for cost-benefit analysis considering unit commitment and frequency stability (FS) constraints. The transient frequency dynamics are considered using an accurate time-domain model based on the discretized swing equation. The proposed method ensures frequency stability criteria, such as frequency nadir/overshoot, rate of change of frequency (RoCoF), and steady-state frequency, are within their allowable ranges following generation contingencies. Simulation results based on a medium-voltage microgrid test case with historical data of load, PV generation, and market price verify the effectiveness of the proposed method.