Most likely your Touch ID fingerprint scanner is perfectly fine.
There are certain rules that iOS uses that govern when your iPhone will prompt you for your passcode, and one of these relates to an 8hr period during which Touch ID has not been used. That alone would explain the scenario in your question (i.e. some nights you’re getting 8+ hrs of sleep, and other nights you’re not).
All of the Touch ID rules can be found in Apple’s iOS Security Guide. In summary though, the rules governing when a passcode is required instead of your fingerprint, are as follows:
- The passcode has not been used to unlock the device in the last six days
- Your fingerprint has not been used to unlock the device in the last eight hours 1
- You have just powered up (or rebooted) your device
- Your device has not been unlocked for more than 48 hours
- You’ve unsuccessfully tried to use your fingerprint on five consecutive attempts
- Whenever you add a fingerprint to your Touch ID settings
- Your device has received a remote lock command
Regarding that last point, this refers to iCloud’s Lost Mode function. For more info you can read iCloud: Use Lost Mode.
Finally, if you’re still concerned about a possibly faulty Touch ID sensor, you can refer back to the above list as a reference point to determine if you’ve been asked for your passcode under different circumstances. If so, you can use that as a starting point if you seek help from Apple.
1 This is most likely the cause in your situation most of the time.