The Principle of Reciprocity states that if you give people something they want, they are more open (and might even feel obligated) to give you something in return.
In the case of lead magnets, you give people a resource for free and they’re fine with giving you their email address in return.