Given the existing ctrl+alt+d keyboard shortcut to Show Desktop, you can use xdotool to toggle show/hide of the desktop. For example, here's a test script that shows the desktop, waits five seconds, and then shows the windows again:
#!/bin/bash xdotool key ctrl+alt+d sleep 5 xdotool key ctrl+alt+d
But it should be noted that if any windows are shown on the desktop, the Show Desktop operation executed by the ctrl+alt+d shortcut will minimize those windows. So, if xdotool key ctrl+alt+d is run from a terminal to minimize a bunch of windows and show the desktop, and the terminal is then restored to run the command again, the other windows won't be restored; the terminal will just be minimized.