I like Alen’s (adw) answer better
Best Answer - Chosen by Voters
At one time people were terrified of being buried alive. There were actual cases of this happening. The gravediggers were always blamed for live burial. Eventually family had to begin the filling of the grave with shovels full of the dirt that came from the grave, then the gravediggers shoveled the rest into the grave. Though some families still do this, in the 20th century, only a small handful of dirt or even a flower has become the ritual.
Encyclopedia of Death.
Chinese Funeral Customs
Family members and other relatives throw a handful of earth into the grave before it is filled.
Funeral Customs - Mexican American
Relatives to throw a handful of dirt on the coffin before the grave is filled.
this doesn’t tell why but is interesting