The kid is five, and it's an android device. You have options without trashing the thing.
Sideload some open source games through F-Droid, set up a simple emulator frontend/app with a few age appropriate games. Lemuroid is a pretty straightforward emulator frontend with a decent UI for a kid to poke the boxart they want to play and just go, but I'm not sure how much you could lock it down to prevent them from borking the settings.
Lock the kid's access to the app store the fuck down. Install an on-device-vpn based adblocker like blokada or rethink dns to block ads across all apps on the device. It might break some games but the overwhelming majority will just fallback to "you don't have an internet connection" functionality at worst.
You can look up how to enable adb on the device, then plug it into your computer and use https://github.com/0x192/universal-android-debloater to remove/disable built-in apps you don't need. There's a ton you can do with adb to tweak the device, but uad is the most user friendly way.
If you want to push programming, others have mentioned a version of swift that's available on the kindle fire. Someone else mentioned Luanti as an open source minecraft clone, which I know is available through F-Droid (but can be quite janky due to not being made for phones/tablets).