Use a screen saver

You can have moving images appear on your screen (called a “screen saver”) when you aren’t using your computer. You might want to use a screen saver to hide the items on your desktop while you’re away.
  1. Choose Apple menu > System Preferences, click Desktop & Screen Saver, and then click Screen Saver.
  2. Select a screen saver from the list.
Your screen saver starts automatically after your Mac has been inactive for a period of time. To deactivate the screen saver and return to the desktop, press any key, move the mouse, or touch the trackpad. If your screen saver is a slideshow, press the Spacebar to pause and resume.

For extra security, you can lock your screen by requiring a password to turn off a screen saver. You can set this type of password in Security & Privacy preferences.