If you buy the S&P500 then someone else sold the S&P500 for the same amount of money. The cash doesn't disappear, it just moves to a different person who presumably sold the S&P500 because they need cash to spend it.
That is quite different than sitting on cash.