This is how and from where you can download firmware files for Apple devices.
How to Install IPSW File on Your iOS Device
You can download and use it to downgrade your device, upgrade it, and restore it to default factory settings. IPSW is a file format used to install the firmware on iPhone, iPad, iPod touch, and Apple TV.