Like @ragingloli said, there are enough people buying the premium versions to more than pay the bills.
Thing is, not all software is about business or money making. In fast, some of the best software isn’t. Canonical, the people behind Ubuntu, get a little money from sales of enterprise-level services, but most of the reason they can afford to exist is that they are a “pet project” of Mark Shuttleworth. In truth, Canonical operates at a loss…. but they operate. If you have a very wealthy person who honestly believes in something, then you can afford to stay in business no matter what. Look at Tesla and SpaceX.
And even then, there are many programmers who will “do the right thing” and write this sort of software for free. Think about it; the more computers that are infection-free, the lower the odds of you getting infected yourself, so if you write and distribute a piece of anti-malware software, you’re protecting yourself anyways.
But it’s not like to costs much to distribute software anyways. With no discs to write, no manuals to print, and no boxes to ship, overhead costs are pretty damn low to begin with. And if you allow your employees to telecommute, you don’t need an office either, so you save on real estate, and the accompanying taxes and utilities costs. All you really need to pay for is employees and a little hardware and you’re good to go… especially if the employees are actually volunteers.
There are many things about computers that break from preconceived notions, and business models are one of the many things that computers have changed. Where is cyberspace anyways? Does it follow national borders or not? How can one steal something when the rightful owner never lost possession of the original? In order to understand how software companies can stay in business, one must understand that software is more like ethereal art than it is like tangible goods and alter their other paradigms accordingly.