There is no definitive answer to why dogs eat grass. However, a survey of 1,600 pet parents conducted by the University of California-Davis may give some insight.
It has been suggested that dogs may eat grass because they don't feel well. As many dogs throw up after ingesting plant material, some believe this may be a way for the dog to rid their system of what is causing them to feel ill.
But, of the 1,600 pet parents in the study, 68% of them said their dogs eat plants daily or weekly. Only 8% said their dogs had exhibited signs of illness prior to eating the plant material. So, it seems there is probably no basis for the hypothesis that dogs eat plants because they don't feel well. Yet, others still suggest that dogs may eat plant or grass material because they have inherited the instinct to do so from their wild ancestors who did so to clean their intestines of potential parasites.
This behavior might be due in part to the fact that dogs investigate with their mouths (and noses, of course) and grass and plants smell and taste good to them. But, things don't need to necessarily taste 'good' for a dog to eat it (after all they'll scavenge in the kitty litter box and pick up cigarette butts from the street!).
It could be that dogs get the occasional craving for greens since they are omnivores (they eat meat and plants). Some vets suggest that eating grass may indicate the dog needs a higher fiber diet. So, you might want to chat with them about that and potentially offer your dog a different food and/or some veggies.
There is usually no reason to worry about the occasional ingestion of grass as long as it isn't coated with potentially toxic chemicals (like fertilizer). But, if you feel your dog is heading straight to the grass to eat each time you take him out you might want to chat with your veterinarian to rule out any medical issues.