How to reset iPhone with passcode or iTunes?

My younger sister recently received my mom's old iPhone 4 as a gift. However, we forgot the passcode. So we want to factory reset it. I have tried hard resetting it, and connecting it to iTunes but neither have worked. It is not connected to any data plan or Wi-Fi network, either.

Data plan nor Wi-Fi have nothing to do with the factory reset. You must first put the iPhone in DFU mode (plenty of instructions online), and iTunes should detect it as being in recovery mode (it is fine) and will offer to restore it. This of course will wipe everything off of the phone.

Once it is restored, you can setup the phone like normal. Just be advised that the iPhone 4 is very obsolete at this point. Most apps will no longer work on it since they usually require a higher iOS version that what is possible to install on that iPhone model.