It's one of their more frustrating habits. You groom a horse, turn it out, and it promptly goes to the muddiest or dustiest place in its field, lies down, and rolls over.
Horses roll for two primary reasons:
1. To scratch an itch they can't get at any other way - especially if there isn't another horse (or even a friendly human) to ask to do it for them.
2. To intentionally cover themselves with mud or dirt. This has a warming effect in cold temperatures and a cooling one when its too hot - it's basically insulation. This is why they pick the dirtiest spot they can find.
Seeing a horse get dirty right after you cleaned it might be frustrating - but they do it for their own comfort.
This horse has found something even more interesting to roll in - the ocean! (He's probably too hot). Image source: T353&4 via Wikimedia Commons.