Why does blender erase transforms after inserting a keyframe?
The keyframe is updated with the current value at the moment you press I or insert the keyframe. After that, the value will not be (permanently) modified any more until you press I again on that exact keyframe.

So if you press I and rotate afterwards, that rotation has no (permanent) effect and is lost as soon as you leave the keyframe. You should rotate first and insert the keyframe afterwards, or at least press I again after rotating, basically to save the modification to the keyframe.

You can insert new keyframes by pressing I on the 3D View and selecting the properties in the popup menu, pressing I on any numeric field in Blender (whether transforms or modifiers/material/constraints properties) or by right-clicking on any field and pressing Insert Keyframes (or Insert Single Keyframe).

In addition, if you want to update any change on the fly you can enable the Automatic Keyframe insertion button on the bottom of the Timeline window. This is the common approach in character animation.



Note that you must insert a keyframe first in which properties you are going to animate. Insert that first keyframe with any of the methods above.