One who gives ghusl to a corpse must have the intention of attaining proximity to Allah the Exalted, and it is sufficient if he has an intention to follow the command of Allah the Exalted.