“Leave it” has a few different variations that all revolve around the theme of a dog learning to show impulse control and choose not to interact with something he or she is interested in. Leave it can be a prompted behavior in which you actively ask your dog to leave something alone (e.g. telling your dog to “Leave It” when they see a squirrel and the dog turns away or ignores the squirrel). Alternatively, leave it can be taught as an automatic or default behavior such that before the dog picks up or eats something they look to you for permission (e.g. you drop a piece of food while cooking and your dog looks at you and waits to see if you give permission to eat the food).
Regardless of if you prefer a prompted behavior or a default behavior, the basic concept for teaching leave it is similar. They both have pros and cons, but either method gets the job done. With a prompted behavior you always have to ask your dog to leave it, while a default behavior will require you always need to notice your dog asking to have something so you can grant permission when it is appropriate.
Emily Larlham of Dogmantics and Kikopup has a great video with step-by-step instructions on teaching a default (she calls it safety) leave it:
And here is an example of one method for teaching a prompted Leave it by Training Positive: