We present an all-optical method for the highly efficient preparation of cold atoms in a specific Zeeman state, such as the magnetically insensitive clock state (m F = 0) or a particular state suitable for quantum information processing and storage. This technique employs a single microwave spectrum, enabling precise determination of the population distribution, microwave polarization ratio, and microwave Rabi frequency individually. By analyzing the microwave spectrum, we can track the population distribution while systematically varying the power or period of the optical pumping field(s). In steady-state conditions, our simplified model, which incorporates resonant and off-resonant transitions, reveals an upper limit to the population purity. Through the optimization of the intensity and polarization of the optical pumping field, we have achieved exceptional population purities of up to 96(2)% or 98(1)% for the desired quantum state. These remarkable results indicate a significant advancement in state preparation accuracy. Our all-optical method introduces an approach to achieving high-purity atomic states while employing novel microwave spectroscopy to accurately detect all unknown parameters, offering valuable insights and potential applications in precision measurement and quantum computation research.