I wrote an answer to a similar question over on Quora, but here's the main point:
In the United States, there's a giant piece of legislation called the Digital Millenium Copyright Act. This contains all of the basic legal concepts that are used to punish digital copyright infringment.
While drafting the bill, legislators recognized that there are many large internet services that allow for the storage of user-uploaded content (YouTube, SoundCloud, MediaFire, etc.) and that these services would face an impossibly difficult game of cat-and-mouse if they would be liable for any infringing content that a user uploaded to their service. They'd essentially have to shut down to ensure nothing illegal was ever uploaded to their servers. This would stifle innovation on the internet and "chill" free speech.
So they added a provision known as the "Safe Harbor Clause".
The safe harbor clause addresses that by saying, "Look, we understand users might try to upload material that they don't have rights to, and it's not really fair to penalize you for the actions of your users, even though the infringing content is now sitting on your servers."
The safe harbor clause proscribes a series of steps that services must follow in order to qualify for the safe harbor provision. As long as your service follows these steps, you should be immune from any litigation due to any infringing content on your site:
- designate and publicize an agent to handle all DMCA take-down
- remove any infringing content (almost) immediately upon
receiving a take-down request
- institute a "repeat infringer" policy to track and remove users whose posts continually receive take-down requests
Terms of service can protect you from your users, but they won't protect you from publishers seeking damages for copyright infringement. There's tons of great, free information here.
I am not a lawyer.