The error is appearing because this is your Mac’s first time installing an Oracle product (like VirtualBox). You’ll need to give the piece of software explicit permission to access the computer. Unfortunately, you have to go look for the prompt.
First, navigate to System Preferences by clicking the Apple icon on the top menu bar and then selecting the “System Preferences” button. From there, click the “Security and Privacy” option.

Under the “General” tab, there should be text near the bottom that says, “System Software from Developer ‘Oracle America, Inc.’ Was Blocked from Loading.” Click the “Allow” button.

Note: This option is available only for roughly 30 minutes after a fresh install of VirtualBox. If this message does not appear, uninstall VirtualBox by opening your “Applications” folder and then dragging the VirtualBox app to the Trash. Remove any leftover files, reinstall a fresh copy of VirtualBox, and immediately open the Security & Privacy menu to see this option.
The installation will now complete successfully. Congratulations on your fresh and functional installation of VirtualBox.