What does OPTIMIZE really do?

all i know is it optimizes programs for better performance.... but how? what does it do exactly?

 

thanks