In terms of codeigniter:
You'll notice that each controller in codeigniter extends the base controller class. Using $this in a controller gives you access to everything which is defined in your controller, as well as what's inherited from the base controller.
Most of the use you'll get out of $this involves calling methods which the base class has loaded for you - $this->load, $this->uri, etc.
If I remember correctly, PHP code in a view is run in the context of the controller, so you'll have access to the controller object with $this from there as well.