Why is it necessary to dry dock the ship with a small stern trim and why it cannot be done in even keel condition?

The required trim of the ship is decided during the meeting of the chief officer with docking master before the ship proceeds to the dry dock. Docking master gives the required information on the desired trim to the chief officer. Chief officer calculates the closest what he can achieve considering the weight distribution.

Whatever the agreed trim, but it will never be zero trim. The ship will never be asked to dock the ship in even keel condition. Why?

I will briefly summarize the procedure of how a ship is made to sit on the blocks.

The ship is brought into the dock with the help of tugs. Then the ship's stern is made to touch the blocks. At this time a diver will go down and will check the alignment of the ship with respect to the blocks. If required the ship can be aligned with the help of tugs as until now the major part of ship's bottom is still floating.

Once aligned, the ship is made to sit on the blocks.

Now you can imagine what can happen if there is no trim. There will be no time to adjust and align the ship with respect to the blocks arrangements on which the ship is supposed to sit.  

Read more about dry docking a ship, here:

A complete guide of bringing a ship to dry dock