It is hard to compare the D5 with D850. The useful DR is better at high ISO on the D5 but for highest quality, low ISO the D850 is a great deal better.
Here is a chart of Bill Claff's PDR (Photographic Dynamic Range that is a more realistic and consistent method of measuring the sensor visual impression of DR.
The D5 has build, slight AF, speed, and weather sealing advantages but the gap is narrowing with the D850.
In everything else that photographers are interested in, the D850 is the camera to beat. It may be the last DSLR Nikon makes for the pro market before moving to mirrorless. If you prefer large optical VF, it might be the last model to have it. The D500 is the best DX camera made but the D850 steals some of its thunder by being so good in crop mode. Personally, a separate mode for crop dimensions really is not needed. I use a D800 and just shoot and crop in post if I have to regardless of lens image circle. If given the choice of D500 plus the cash difference, or a D850, it would be the D850 all the way. But I am less interested in long telephotos and sports than general and studio photography.