What is the "leave it" command?
A "leave it" command tells the dog that something is off limits at that moment/to walk away from it. For some dogs maybe a person or a dog will be a "leave it", we don't have to say hi to every single person or dog we see. Or maybe your dog might be reactive to other dogs so you could use a "leave it" command before the situation escalates when your dog sees another dog.
It could be that squirrel, bird or bunny you don't want your dog chasing. Or that tempting garbage on the sidewalk your dog would love to pick up.
How to teach it
You will have your dog on leash, you want to put something low value on the ground like a boring dog treat and you will reward with a better treat. The treat that will be on the floor should be further away from you/your dog so maybe set it by the wall and you will be walking back and forth past it with your dog. Give your dog space to be successful initially so don't walk super close to it. You can have several feet between you/your dog and that treat on the ground.
Timing matters, as you are walking the moment your dog physically tries to go for the treat on the ground say "leave it" and keep walking keeping an eye on your dog. The moment your dog physically "leaves it" and starts walking with you, mark it with your positive marker (yes or good boy/girl) and reward immediately. Then walk back the other way and repeat. Repeat, repeat, repeat. You will get to the point where your dog isn't going as much for it and eventually just walks past it. That is called a breakthrough so make sure to praise them and reward them!!! No, they did not forget about the treat on the ground, they are starting to learn that it is rewarding to leave it.
Eventually you can walk closer past it and once your dog masters this then step it up with something of better value on the ground. Since it is something higher value like a better treat or a toy remember to give your dog once again space to be successful. Just because they can leave a boring treat on the ground now walking right past it does not mean they will be able to with a higher value treat or toy on the ground so go back to step one.
Start out teaching this command inside of your house and then once your dog gets good at it, take the practice outside.
Practice every single day.
Things to keep in mind
All of the 'leave its' I mentioned above are very difficult ones. For a friendly dog leaving a person or dog that they want to greet is definitely one of the most difficult leave its. For a dog with a high prey drive leaving that squirrel, rabbit or bird takes so much self control. For the dog who just finds garbage the most exciting, high value find leaving it is difficult! You have to perfect your "leave it" command with lower value objects inside of your house first then start working on it outside. So before you can expect your dog to leave the most exciting things, you need to keep perfecting that "leave it" command.
When working on "leave it", even if you're not at the point where it is perfect and it takes your dog perhaps half a block to leave whatever you told them to leave, it is still important to reward them the moment they do "leave it".
Impulse control should be rewarded immediately!