The S&P 500 (^GSPC 0.26%) just hit a fresh record high a couple of days before I wrote this, but that isn't scaring me away from the market. In fact, I own shares of the Vanguard S&P 500 ETF (VOO 0.28%), and plan to incrementally add to my position, even with the market looking a bit on the expensive side.
As is the case with most investing topics, legendary billionaire Warren Buffett has shared some wisdom on this matter. He has said that a low-cost S&P 500 index fund is the best investment most people can make.

Image source: The Motley Fool.
His reasoning? "American business -- and consequently a basket of stocks -- is virtually certain to be worth far more in the years ahead."
This quote from his 2016 letter to Berkshire Hathaway shareholders is equally valid, no matter what the market is doing now. Over long periods, the S&P 500 has delivered 9% to 10% annualized returns, and there's no reason to believe this will change.
Buffett's favorite approach to index fund investing
However, it's also worth noting that Buffett has also advised investors not to put all of their money in at once. One of his quotes about index fund investing is, "Just pick a broad index like the S&P 500. Don't put your money in all at once; do it over a period of time."
One specific strategy Buffett has advocated is to average into an index fund over 10 years. In other words, instead of aiming to invest $50,000 in the S&P 500 today, maybe plan to invest $5,000 every year for the next decade as a way of dollar-cost averaging. Doing so prevents you from overinvesting when the market is a bit frothy, and mathematically will result in a solid average price over time.