One explanation for why dogs roll in the grass is an ancestral instinct to mask their scent.
Rolling in the grass to leave their scent can be a way of telling other dogs that this territory belongs to them.
A soft patch of grass might simply feel good to your dog. It is a chance to stretch out, rub their back, and soak up some sunshine.
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.