One of the goals of learning touch typing is to type not looking at the keyboard. The on-screen keyboard helps you in achieving this.
The on-screen keyboard reflects the state of the actual keyboard.
It displays the current keyboard layout and the state of all the keys. There is no need to look at the actual keyboard—you see it on the screen.

Swiss-German keyboard. The right Shift is pressed.
Moreover, the labels on the keys of your actual keyboard may not represent the characters you get (e.g. when you switch to Spanish or Dvorak keyboard layout while using the US keyboard). Looking at the actual keyboard will not help in such cases. This is when the on-screen keyboard becomes invaluable.
The on-screen keyboard highlights the next key to press.
Another helpful feature of the on-screen keyboard is highlighting the next key to press. It even proposes to press the keys Shift, Caps Lock, and AltGr when necessary. It teaches you when and what key to press.

Spanish keyboard. The next key is the acute accent.
This feature makes your learning faster, because you do not have to search for the next key—computer does it for you instantly.
The on-screen keyboard also draws an arrow (a line) from the corresponding home key to the next key, which shows the proper movement of the finger. It is especially useful for beginners.
The on-screen keyboard shows the key you've actually pressed.
If you make a misprint, the on-screen keyboard highlights the key you've actually pressed. This allows you to find the next key literally by touch, looking only at the on-screen keyboard.

The key "b" is required, but the key "v" is actually pressed.
It also highlights other keys you press—Ctrl, Alt, Backspace etc.
Conclusion
The on-screen keyboard helps you not to look at the actual keyboard when you learn touch typing. You look only at the screen, find the keys by touch, and your touch typing skill grows quickly.