It's usually not necessary to change any security settings, and as a rule you shouldn't.
To make a one-time exception to the security policy, follow these instructions. They apply to Installer packages and other installable items as well as applications.
Some defective software installers may fail when Gatekeeper is enabled. Think carefully about whether you really want to run such an installer. If you do, temporarilychange the setting to
Allow applications downloaded from: Anywhere
When the installation is done, revert the setting.
Some applications that don't have a developer signature have been reported not to launch the first time unless Gatekeeper is disabled. The warning message from Gatekeeper is that the application "is damaged and can’t be opened." Again, think carefully about whether you want to trust the application. If you do, disable Gatekeeper as above, launch the application, and then re-enable Gatekeeper. If you still get the warning, delete the application. Do not follow advice to weaken the security of your system in order to run defective third-party software.