iTunes Error 21 is the most common error users face while performing the restore on the iPhone. Device Firmware Upgrade mode known as DFU mode, this mode allows you to restore your iDevice with an original iOSversion or a custom iOS version.
To resolve the iTunes Error 21 in order to restore your iPhone/iPod touch, connect to your device into DFU mode first to get by following the instructions according to your device, The steps below will help getting into DFU mode in case you do not know how to:
Connect your device to your PC or Mac via a USB cable and launch iTunes.
Hold Home + Power button for 10 seconds.
After 10 seconds release the power button off, but keep the Home button pressed until iTunes a little device in recovery mode you find there.
Once your device into DFU mode, you see nothing on the screen, only a black image. (See above)
If you successfully performed these steps, iTunes will give you a message that a device was found in Recovery Mode and restore it. Now you SHIFT + Restore in iTunes button to press together, so that iTunes can refer to the iOS firmware to which you are restoring to. If you have followed these steps you should be able to get rid of the iTunes Error 21 while restoring your iPhone. Now you have fixed iTunes error 21, and your iPhone can be restored to an ipsw custom firmware.