First, "jailbreaking" is a term used with iPhones. With Android phones, you root the ROM - that's just basically adding the file su to one folder.
It allows you superuser access to the operating system that Android is running on (Linux), which allows you to do just about anything - including removing all the files from the phone, turning it into a hand warmer, so I'd advice that you read a lot more about rooted phones before trying it.
It also prevents you from getting any updates (including security patches, but also newer versions of Android, and an S5 may still be lacking the latest version).
Once you root it, even if you revert it to stock, there may still be signs left, and the warranty will be voided.