One explanation for why dogs roll in the grass is an ancestral instinct to mask their scent.
After their sensitive noses have picked up the smells of other animals, they may feel the need to mark the area as their own again. Rolling in the grass to leave their scent can be a way of telling other dogs that this territory belongs to them.
Observe the way your dog rolls in the grass to understand if it feels good for them. A slow, relaxed roll with legs kicking around in the air shows that your pet is happy.
Just like some humans choose to wear bold-colored clothes to make a statement, dogs use their behavior to express their unique character.
There can also be a practical reason for your dog to roll in the grass. Often it helps them to get rid of something on their back.