I'd get the 2017, iPad 5th generation.
Fairly up to date, modern specs mean it will have longest longevity.
I would ONLY consider an iPad 4th gen if you can find a 64 GBs or 128 GBs model cheap as it has ended its iOS life at iOS 10.3.3 and while there are many apps still available that require iOS 10.3.3, the iPad 4th gen can NO LONGER have its iOS upgraded to anything newer as the iPad 4th gen is a 32-bit hardware device and all future iOS versions are all going to be 64-bit iOSes and will be all incompatible with older 32-bit iDevices, like the iPad 4th generation.
Also, an iPad 4th generation is nearly 6 years old,now!
Make sure if you purchase ANY older iPad models used/second hand that NONE of them have user Activation Lock on them as Activation Lock cannot be defeated or circumvented.
Good Luck to You!