iPhones and iPads are locked-down devices. You can only install apps Apple has approved, and you can't tweak the underlying system like you could on a Windows, Mac, or Linux system. Jailbreaking is the act of escaping this figurative "jail."
Apple doesn't like jailbreaking, and they go out of their way to make it more difficult. The jailbreaking community and Apple are engaged in a game of cat-and-mouse. Jailbreakers work to make jailbreaking possible before Apple blocks their latest tricks.
Jailbreaking is the act of gaining full access to an iOS device. Jailbreakers generally locate a security vulnerability and use it to escape the locked down environment, giving users full control over their devices.
Thanks to the US DMCA, jailbreaking an iPhone is completely legal. Laws may vary in other countries.
Source
Inspired by ios.cfw.guide