Basically there are two problems to address: first - bed inclination and second - uneven bed surface.

There are different algorithms dealing with one or both problems.
Most specialists insist that bed should be flat and most people use glass as the top to achieve this. And this eliminates second problem and require to solve only the first one.

To find bed inclination - autolevel algorithm usually do three points test and get transformation matrix. This matrix then used to transform XY motion to be parallel to the surface.

For uneven bed surface more complex algorithms used. But usually bilinear mesh used that could be looked as the whole square surface subdivided into smaller ones with individual inclinations. Basically algorithm from XY coordinates determines the sub-square and then applies corresponded transformation for it's inclination.

The transformation fade out with the Z going up and usually applied within first 10mm over the bed level.

There is UBL (Universal Bed Leveling) algorithm that deals with two problems simultaneously. Only once it probes the whole bed with many points to produce two dimensional mesh to address second problem.
And for each next auto level it does three points test to find the whole bed inclination. Then it combines measured inclination with the mesh information stored in memory. UBL assumes that surface do not change but only it's inclination could change.

In all cases this is all about to guarantee that the first levels of filament will lay on the bed evenly and will stick to it.

it just sets the floor to a non-zero Z value, layers are all bumped up uniformly. iow, if you had 1mm layers, and 5 layers, it could use 1-6 instead of 0-5. it's more precise, but that's the main idea: min z height – dandavis – 2018-08-27T19:24:25.530

This is a great question and I would really like to see some citations in some of these excellent answers. – linhartr22 – 2019-03-28T01:36:31.800