iCloud is a service that stores all of your data in the cloud, including messages. If you want to disable the iCloud service on your device, you can do so by going into Settings > iCloud and toggling off the iCloud switch. If you want to delete all of your messages from iCloud, go into Settings > Messages > Keep Messages and toggle it off.
Messages in iCloud: Everything You Need to Know
Messages in iCloud – Storage and How It Works
According to Apple, when you disable and delete messages in iCloud, it means that the messages will no longer be synced across your devices. In other words, if you have an iPhone and iPad that are both connected to iCloud, and you delete a message on one device, it will not be deleted on the other device. There are two ways to disable and delete messages in iCloud. The first way is to go to Settings > Messages > turn off “iCloud Message Syncing.” The second way is to go to Settings > General > Reset > Erase All Content and Settings. This will delete all of your messages from iCloud, as well as any other data that is stored in iCloud. If you want to completely get rid of your messages, then you need to delete them from both iCloud and your device.