I’ve often read that they do this to settle their stomachs, but I see it more often when dogs are excited or bored. I try to discourage it after letting them have a few nibbles. If your dog chronically eats grass they may have poor gut health and you might want to consider Bernie’s Perfect Poop, which contains enzymes, probiotics and prebiotics