A lot of "free" software makes money by agreeing to sponsor other software (like browser extensions or adware). Basically, every time the free software is installed, the malware gets installed with it, and the malware author pays the free software author.
Edit: Also, some download sites (like CNet) do this by wrapping free software in their own installer which installs this malware. Instead of the free software author being paid, the download site gets paid.
To avoid this, never use the automatic install. Always do a custom install. Usually that will bring up a step where you can choose which components to install, and the malware will by default be selected to install. Unselect it.
When you uninstall the software, it does not...