Samsung also makes very lucrative deals with carriers, and most of the time those carriers want to prevent you from rooting your phone. Recent models from AT&T or Verizon are notoriously difficult to exploit, and all the U.S. versions of the Galaxy S7 are locked up and encrypted. There might not ever be a way to root them. This isn’t true for unlocked models sold outside of North America though.
To root most Samsung phones you’ll need to use a program called Odin. It’s a low-level firmware flashing tool that can push image files to the storage and overwrite existing images. You’ll also need the correct USB drivers for Windows computers. If you’re using a Mac computer or running Linux, the software that flashes images is called Heimdall. They both work essentially the same, and carry the same risks — if you try and flash the wrong image or a bad image, your phone isn’t going to be able to start. While this is often recoverable, know that there is always a chance you can ruin your phone or tablet, and your warranty is voided as soon as you begin.
Also, many Samsung phones ship with Knox security enabled. Knox is part of Samsung’s special “Samsung Approved For Enterprise” feature where personal and work environments can be separated in a way that allows both to coexist on the same device. Knox can pose special problems when trying to root a phone that uses it, and it has a software counter that can show when device firmware has been tampered with. This means it’s very easy for Samsung to void your warranty if you start fiddling with things.
Otherwise you can also try commercial rooting apps like kingo root or towel root.