As mentioned elsewhere, while code is a type of data, it is useful to reserve the word data for that which is not code.
Now, there are various types of code that processes code, and the virus is one. The only goal of a virus is the feeling of self satisfaction, based on the misery of others. For even if 'harmless', does the author expect that his victims will decide to let it stay? But it is simply a fact of life. Because of virus writers, even harmless ones, we had to get used to things getting slower as often as they got faster.
Some people blame Microsoft, but this is incorrect. Microsoft represents the hobbyist computer industry--the microcomputer--which surely had to have a top dog?
Microsoft gained their supremacy through machines which were supposed only to be used at home: the IBM PC officially introduced the microcomputer to business, and IBM was happy to forgo permissions.
Self-modifying code is a favourite of tinkerers and theoreticians: the home computer thus had negative reason to have permissions.
One might think that the virus is one. But, what a theoretician sees as a possibility seldom justifies an increased cost. At least, surely the market would insist on a demonstration?
An anarchic market, and a market trading things beyond its knowledge, would simply pretend not to hear the theoretician.
Permissions arrived, but virus writing by then had become an industry and a culture: only the front gate had been secured.
Ken Thompson's lecture, 'Reflections on Trusting Trust', is essential reading to anyone who is even only marginally interested in computer theory.
Or the history of the last 50 years, inasmuch as computers are part of that history.