Activation Lock is a feature that was added in iOS 7 which is intended to prevent unauthorized users from restoring the phone to factory settings to bypass any other security means that were configured on the device.
Activation Lock is aimed at preventing theft of iOS 7, or later, devices by rendering the device useless, unless the user can enter correct Apple ID credentials. After restoring the device, if iCloud (in particular, Find My iPhone), has previously been enabled it will prompt for the login information of the Apple ID that had been activated on the device previously. This should prevent malicious users from wiping the contents of the phone and then using it.
For more information, refer the Apple Support document on the working of Activation Lock: