What Is Code Optimisation?

In this lecture we're going to look at the theory behind code optimization. What exactly is code optimization, and when should you do it?