There are a number of different ways to legally get free games online, such as freeware and giveaways. Torrents on the other hand are a popular way for copyrighted games to be distributed illegally.
Some game designers and publishers release their titles as freeware, meaning that they are free to download with no compensation. A variant is shareware, which may come in the form of a limited playable demo.
Copyright holders also sometimes release older commercial games that they no longer expect to sell as abandonware, and a number of websites are dedicated to cataloging these releases. Digital game download services like Good Old Games and Steam also periodically give away games as a part of promotions or contests.