There are a few things you can try to narrow down if it’s software or hardware related.
Firstly do a Forced Restart If your iPhone, iPad, or iPod touch won't turn on or is frozen - Apple Support
You can also “Reset All Settings”, this will not remove data or Apps, this will explain further What would happen if I reset all settings in an iPhone
You can also try a third party camera app that allows the switching between the two lenses, if yours still doesn’t work then it could be hardware, for which you will need to make a Genius appointment.
One last thing is to try an Erase/Restore which basically wipes your device, it can be done from the device itself or via iTunes, but make sure you do a BackUp first via iCloud or iTunes. Restore your iPhone, iPad, or iPod touch from a backup - Apple Support