Simple answer, you can't.
You can gauge engine life with tests like compression level and oil content analysis, will give you an idea as to the general condition of the engine, and similarly what you find in a tranny pan and the condition of the fluid, along with pump and line pressure readings can give some idea of how healthy a tranny is.
But I've seen relatively new engines blow up without warning, and I've seen worn out, rattling old smokers run for years...there just are no guarantees when it comes to cars...machines are by nature a bit unpredictable.
All you can do is give it what it requires, and most times it will return the favor.
My favorite general indicator of engine condition is a vacuum reading. I always take a vacuum gauge with me when looking at a used car...if you know how to interpret the reading, it can tell you a lot about what's happening in there..you can spot problems like low compression, worn out timing valve components and valve problems.
A good hard look at the underside of the car is essentail to, things like worn out bushings and such are not that big a deal as they can be replaced...but you want to look for actual structural issues that are not easily repairable and are a safety issue, like front cradle (subframe) to body mount corrosion, and rust around strut mounts and other suspension locating/mounting hardpoints...when these areas go, the car is basically junk, the cost of repair exceeeds the car's value in most cases...