First you need to make sure macOS 10.8.5 is completely up to date with all patches including security patches before you can access the App Store (unless something recently changed anyway).
You can use the information in this Apple article to download macOS 10.15 Catalina:
How to download and install macOS - Apple Support
If you still cannot download 10.15, then use the instructions in that same Apple article to download the macOS 10.11 El Capitan installer. Make sure to read the instructions in the above article very carefully since you will need to run a .pkg file from the mounted .dmg you downloaded in order to extract the real installer into the Applications folder.....which you will need to run separately since it won't start automatically. I'm providing the actual download link direct from the Apple servers here just for reference:
http://updates-http.cdn-apple.com/2019/cert/061-41424-20191024-218af9ec-cf50-4516-9011-228c78eda3d2/InstallMacOSX.dmg
Another option would be to boot into Internet Recovery Mode using Command + Option + R to see if you can access the online macOS 10.15 Catalina installer. Unfortunately some Macs will just boot into the online macOS installer which originally shipped with the Mac from the factory.
If you have access to another Mac from 2012 to 2019, then you can use that Mac to download & create a bootable macOS 10.15 USB installer. Or if you have a Mac from 2007 to 2015, you can create a bootable macOS 10.11 USB installer.
Create a bootable installer for macOS - Apple Support
Edit: You can download macOS 10.11 El Capitan installer using any computer & OS which can access the Internet, then copy the download .dmg file to this computer so you can mount the .dmg file and run the included .pkg file to extract the real installer into the Applications folder where you will then launch the "Install OS X El Capitan" app.