Because they believed their infant would have a better chance of surviving in the desert.

The child mortality rate from disease and malnutrition in Arab settlements was horrendously high, and it was believed that sending the child into the healthier environment of the desert increased the child's chance of survival. - Gabriel, Richard A. Muhammad: Islam's First Great General. Vol. 11. University of Oklahoma Press, 2011.

I am no expert in 6th century Arabic health, but you should not presume "chance of survival" in Mecca would be better than in the desert. Historically, urban settlements tended to be demographic death traps, much of which took the form of child and infant mortality. It's a natural consequence of concentrating a population into an urban settlement, wealthy or otherwise.

For reference, this was true for Medieval Europe:

Medieval cities always suffered distinctly higher death rates than did the country side. Infant and child mortality was always high in these societies, but in the cities the rate was twice that of the countryside. - Hoffmann, Richard. An environmental History of Medieval Europe. Cambridge University Press, 2014.

And during Classical Antiquity: