It depends on your purpose. Many people buy an iPod touch just to keep it in the car or to bring it to the gym and for that purpose i really recommend getting the 6th gen. It's almost the same thing as the new 7th gen (except older A8 chip and only 1 GB of RAM) so it won't get iOS 13 when it's released, but other than that it should do the job just fine on iOS 12. Apps will work with iOS 12 too, atleast for the next couple years.
However i can't recommend a 5th gen iPod touch anymore. It's horribly slow on iOS 9.