The Undo History keeps track of all of your changes and puts it in the Undo History docker. This docker is sometimes by the Layers docker in another tab.
Undo History docker shows all of the actions you have previously taken.
The Undo History can get you back to a specific state much faster than Ctrl + Z can. All you have to do is select which state you want to revert to. Your canvas will update accordingly.
Undo History rows have different states that can appear. You can see these paint strokes have been merged, called Cumulative Undo.
If you do a lot of painting, Krita might start to merge the brush strokes together. This is called Cumulative Undo/Redo. You can right-click in the docker to enable this setting. This feature is off by default. When it is on, there are a few options that will appear when you right-click in the Undo History docker.