"To buy the index" refers to investing in a financial product called an index fund, which aims to replicate the performance of a specified stock market index, such as the S&P 500. By buying the index, one is essentially purchasing a diversified portfolio that includes all (or a representative sample) of the companies included in that particular index. It is a way of investing in the overall market rather than individual stocks.
Full definition