Jailbreaking?

As we all know jailbreaking is illegal. But there is a process that is legal. It is on the tip of my tongue and can't get the name for anything. Do any of you guy know the name of the process and how to do the process? So I can open all possible apps functions of. And if you do how do I go about proceeding so I can get the most out of my phone. I am using the Apple iPhone 3GS by the way. Thanks in advance.