Welcome to iMore!
You can absolutely use the old iPhone as a Wi-Fi-only device that can still use iMessage, FaceTime, and other apps included on iOS and that you've downloaded from the App Stores. It sounds like you've already restored the device to its default settings, which is the first step. If you haven't, go to the phone's settings and select General > Reset > Erase All Content and Settings. After restoring, and during the set up process, you will need to insert a functioning SIM card temporarily into the device. Once you've completed the set up process, remove the SIM card from the old device, and you will be able to use it without issue.
You will need a SIM card to set up your iPhone as a Wi-Fi-only device, but only temporarily. After that, it'll work SIM-free.Note that after rebooting the device, you may get the notification to insert a SIM card; however, this message is easily dismissible using the "Cancel" button in the alert. If you have a non-operational SIM card handy, then you could insert it into the old iPhone to keep the messages from appearing occasionally.