Understanding cheackboxes

Basic HTML and HTML5: Create a Set of Checkboxes

I find this topic very confusing. I don’t understand why they need to use the attribute “for” in the “label” element. What is the purpose of the “for” attribute in the “label” element?

to link the label with the input for accessibility, and for them to be linked even if you don’t nest them so you can still click on the label to select that input