Picture this -- you've got a family member who changes the password on a device that you've given them, and promptly forgets it. Or, maybe, a child has locked a device with a passcode that didn't have one before, and either denies it or just doesn't remember the code. What do you do?
This is not how to circumvent an iCloud lock for a device you don't own. If you legally own the locked device, and would like to use it again and have the proper credentials, here's how to do it.
With iTunes
If you've ever synced your iPhone or iPad with iTunes, you can restore your device. In doing so, it wipes out the data on the device since the last backup and its password preventing you from accessing it.
Connect the device to a computer running iTunes. Once the initial handshake is done and the Set Up Screen is reached on the device, click the Restore button as shown, and not Restore Backup.
If Find My iPhone is enabled
If, before the unfortunate password incident occurred, you configured "Find My iPhone" through iCloud, you can use that to erase and restore the device, assuming it is connected to wi-fi or wireless.
From another device, go to the online iCloud device locator, and sign in with your Apple ID password. Select the device you want to erase, and click Erase.
Following the erase procedure, you can restore from a backup, or set up the device as a new one.
Failing all that...
There is a last resort for users to try -- Recovery Mode. Plug the device into a computer, and launch iTunes.
On devices with a mechanical home button, press the Sleep/Wake button and the Home button at the same time past the Apple logo, until you get the recovery mode screen.
On devices with a solid state Home button like the iPhone 7, press the Sleep/Wake button and the volume down button, again past the Apple logo, until you get the recovery mode screen.
Following the iTunes connection, hit Restore.
Following the restoration process, the device will be able to be set up and use.