Solar activity undergoes a variation over time scales of several months known as Rieger-type periodicity, which usually occurs near maxima of sunspot cycles. An early analysis showed that the periodicity appears only in some cycles, and is absent in other cycles. But the appearance/absence during different cycles has not been explained. We performed a wavelet analysis of sunspot data from the Greenwich Royal Observatory and the Royal Observatory of Belgium during cycles 14-24. We found that the Rieger-type periods occur in all cycles, but they are cycle-dependent: shorter periods occur during stronger cycles. Our analysis revealed a periodicity of 185-195 days during the weak cycles 14-15 and 24, and a periodicity of 155-165 days during the stronger cycles 16-23. We derived the dispersion relation of the spherical harmonics of the magnetic Rossby waves in the presence of differential rotation and a toroidal magnetic field in the dynamo layer near the base of the convection zone. This showed that the harmonic of fast Rossby waves with m=1 and n=4, where m (n) indicate the toroidal (poloidal) wavenumbers, respectively, perfectly fit with the observed periodicity. The variation of the toroidal field strength from weaker to stronger cycles may lead to the different periods found in those cycles, which explains the observed enigmatic feature of the Rieger-type periodicity. Finally, we used the observed periodicity to estimate the dynamo field strength during cycles 14-24. Our estimations suggest a field strength of 40 kG for the stronger cycles, and 20 kG for the weaker cycles.