I agree the odds are against you if you start investing right now. But still, analysis has shown that the only way to get long term returns that match the long term averages is to stay invested regardless of what the market is doing short term. I think this is because of another fact revealed by modern analysis: All of the investment gains that push up an average return, are earned in those few days of extraordinary market increases. All the other market numbers year in and year out, are just random noise that can be ignored. So - if you're not in the market on those extraordinary days you're not going to keep up with the long term S&P or whatever other index you like.
But yes, maybe with the market so high then real estate or some other alternative less linked to the economy, might be a better choice. If you have the analytical skill to identify the better alternative.
From my early days: Nice lady at Fidelity said why do you have this one account with so much cash when the market is rising? I replied that's what's left of my first significant investment in Fidelity Magellan back when Peter Lynch was a celebrity for beating the market year after year. That's the remaining half of what I put into Magellan. "Oh."
I didn't tell her this Fidelity account was my after-tax account while my long term investing was elsewhere in a Deferred Compensation (IRA) plan that I was locked into with my employer. Previously I had accepted a Fidelity offer to assign a Personal Investment Advisor and then learned when we met him that he wouldn't even look at that other half of my savings in the employer plan. We thanked him and walked out, that wasn't retirement planning advice at all!