How does foam insulate?

Can you answer this question?