If the machine was originally sold without an optical drive, then there must have been some other way of recovering / installing the OS - presumably over the network, and you should have no problem installing MacOS on such a machine, certainly as far back as Mavericks.
If the machine did have an optical drive, then an OS install disk will almost certainly be available from somewhere, but not from Apple!
However, that said I think your position is not entirely rational. On the one hand, you tell us that you want a machine to browse the internet. On the other you apparently want to buy a machine so old that Apple no longer support and provide security updates for the OS. And at the same time you are concerned about viruses infections. This is truly a PC mindset!
If you are looking for a machine to surf the internet then you need something where you know the OS will continue to receive security patches or can be updated so that it will. If you want a Mac, then that means it must run High Sierra or later - and that will soon be Mojave as Apple’s release cycle inexorably moves on! This does not mean that you need ultra-modern hardware - I have a MacBook Air here from Mid-2012 that is happily running Mojave, and I’m pretty sure that I’ll be able to upgrade it to Catalina - but you need to carefully check any Mac significantly older than that against the Apple OS / Hardware compatibility lists.