It is recommended to upgrade your iPhone 8 to iOS 12. iOS 12 is a free, major software update available for all eligible iOS devices. A major iOS software update named with an incremented version number is released by Apple every year. iOS 12 was released this year on 17 September 2018.
An iOS update helps you get more out of your device that you already own via free software update. iOS 12 is also touted by Apple to be a evolutionary update with a focus on performance. Thus, it is recommended to upgrade your iPhone 8 to iOS 12.
It is obvious to be concerned about safety of your data. To ensure that you don't lose access to your data, it is recommended to have a full backup of your device. If you use a Mac or a Windows computer, you can use iTunes to perform a full backup of your iPhone. In case you don't have a computer, you can also choose to backup your iPhone to iCloud over-the-air. Do note that the basic (free) tier of iCloud provides 5 GB of storage space.
To enable iCloud Backup, on your iPhone go to Settings app → Your name on top → iCloud → iCloud Backup and turn it on.
Messages exchanges via Messages app are backed up to iCloud as well. WhatsApp has an in-app mechanism to take chat backup which you can use. (Behind the scenes, WhatsApp also uses iCloud storage for backup).
Last, to ensure safety of your photos, you can enable iCloud Photos in Settings app → Your name on top → iCloud → Photos and turn on iCloud Photos.
Don't forget to make sure you have enough iCloud storage to enable all the aforementioned data backup. You can buy additional storage by choosing the desired monthly plan.
Note that apart from an yearly major update, a bunch of minor updates are also released by Apple frequently. iOS 12 has introduced the ability to turn on automatic updates which you can use. To turn on automatic updates, after installing iOS 12, go to Settings app → General → Software Update and turn on Automatic Updates.
It is a safe practise to have all the data backed up before upgrading iOS. The way the process is designed, OS upgrade doesn't affect user data or any installed apps on your iPhone and is generally safe to do so. Only recommendation is to keep the device battery charged/plugged in to a power source to ensure that the device doesn't run out of battery while update is in progress.