A few years ago there was this useful tool that was shared on iOSGods which came in handy when picking up a new boxed device. However, that was not maintained and did not support the latest devices being released, but now there's a new and better version by Reincubate!
https://reincubate.com/lookup/
What this does is using your device IMEI or Serial Number (which are also available on the back of the box), it calculates various device information; the most important one arguably being the iOS version. Some use-cases as mentioned on their website:
When buying iPhones or iPads on eBay, users may want to confirm the specs (particularly the device's age and storage). With the serial or IMEI on the listing, they can confirm specs and even whether the device was distributed locked. Here's an example serial lookup of a device that was sold carrier-locked.
Developers often need to test their apps on specific versions of iOS. Trying to find second-hand devices with an older iOS is like panning for gold, but we can identify the version a device shipped with, ruling out a bunch of listings.
Sysadmins responsible for fleets of devices only get limited specifications and device data from MDM tools. Enterprises and institutions already use the technology behind Reincubate Lookup to enrich their device inventory data.
NOTE This will not be accurate on used or refurbished devices,