In German, pronouns, some verbs, and also some adjectives clearly rule a specific case (these are rules you simply need to learn with the word). Beyond that, there is more generic reasoning for dative and accusative (and genitive, obviously, which was not part of the question)
Accusative typically denotes the direct object (the receiver of an action) of a sentence, the
"victim".
Dative initially (and literally, from Latin dabo - to give) means:
The case of the receiver of something that has been handed over.
The "something" doesn't necessarily have to be a physical object, it can also be knowledge or even a statement (like in "jemandem etwas sagen"), or help" (that is why "helfen" requires the dative, same in English, BTW).
This is what it is used for in most languages, German has some more usages for dative beyond that (most of these are heritage from corresponding Latin forms):
- Dativus (in)commodi - Denotes to whose (dis)advantage something happens: Er wäscht ihr die Haare
- Dativus ethicus - Denotes some ethic involvement: Mach' mir bloß keinen Ärger
- Dativus possesivus - Denotes ownership: Mir tut der Kopf weg
- Dativus judicantis - Denotes origin of judgement: "Mir ist es zu kalt hier drin*
- Dativus finalis - Denotes purpose. Recent example handled here, the inscription on the Berlin Reichstag building Dem deutschen Volke.
Some of these examples are getting outdated in modern German, standard language tends towards using a pronoun instead of expressing through a grammatical case.