What is the purpose behind restarting your computer after an install or something, and why is it necessary some times and unnecessary others?

thanks