Anti-virus software is a tool for prevention of malware infection. Since no anti-virus is 100% foolproof, even a computer with an an existing anti-virus can become infected. The same is true if there is no anti-virus installed. Once installed it may or may not detect an infection if one is present but it is better than leaving your computer unprotected.
There is no requirement for the system to be absolutely clean before installing an anti-virus as you can install one on an infected computer. However, there are some malware infections which may interfere or prevent successful installation. Depending on the malware infection, there are specialized malware detection/removal tools which can be used prior to installation. Many anti-virus vendors also offer free LiveCD/Rescue CD utilities
that are used to boot from in order to repair unbootable or damaged systems, rescue data, and scan the system for malware infections. In some cases this may be necessary first in order to stabilize the system and allow for successful installation.
If installation is successful, than a full scan should be completed immediately. If you cannot install the anti-virus, you can always perform a series of online scans first.Eset Online Anti-virus Scanner
is one of the more effective ones.
Keep in mind that an anti-virus program is not enough because it alone does not provide comprehensive protection. Please read Supplementing your Anti-Virus Program with Anti-Malware Tools
which explains why.