Activation lock keeps your Apple device as well as information safe in case if it gets lost or stolen. However it is always advised to keep it on but still, if you want to turn it off then you have to go through a procedure. You can do so by entering the correct Apple ID and password.
If you erased your device accidently then you will have to enter the credentials to set up the device. Or if you bought the device from others then ask the owner for the activation code. Get Help for Fix to Unlock Apple Device