The aim of spyware is to collect information about how you use your computer as well as information on your computer so that the hacker who controls/monitors the spyware can use the information against you.
The information collected must somehow be transmitted to the hacker for the hacker to be able to make use of it! This is invariably done via an internet connection. In fact, this unauthorised traffic is often the key to detecting and preventing spyware.
Ant-virus software and firewalls are effective against spyware as they are able to detect and/or block the unauthorised connection.