The following was original written in answer to a question on the topic on Quora.
Nominative: Subject case. The thing performing the action. Marked below in bold.
Accusative: Direct object case. The thing being acted upon by the action. Marked below in italics.
Dative: Indirect object case. The thing receiving the action. Marked below in bold italics.
Genitive: Posessive case. Marked below with ALL CAPS.
Consider these nouns, all masculine (der in nominative):
Der Junge (the boy)
Der Knochen (the bone)
Der Hund (the dog)
Der Nachbar (the neighbor)
Consider this sentence:
Der Junge gab dem Hund DES NACHBARN einen Knochen
(The boy gave the NEIGHBOR’S dog a bone)
Because of these inflections, German is able to reverse word order while maintaining the same meaning, but creating subtle changes in emphasis:
Dem Hund DES NACHBARN gab der Junge einen Knochen
Einen Knochen gab der Junge dem Hund DES NACHBARN
In each case, the noun that comes first gets added emphasis. This sort of highly flexible sentence structure is virtually impossible in modern English without resorting to prepositions or other constructions.
There are other ways case is affected, particularly by prepositions. The dative prepositions always cause nouns that directly follow to be dative:
Aus, außer, bei, mit, nach, seit, von, zu, gegenüber
The accusative prepositions always cause nouns that directly follow to be accusative:
Bis, durch, entlang, für, gegen, ohne, um
Finally, these flexible prepositions can be either dative (if static) or accusative (if implying motion or change) depending on the situation:
An, auf, hinter, in, neben, über, unter, vor, zwischen
In dem Zimmer is dative and therefore means in the room, whereas in das Zimmer is accusative and thus means into the room.
There is more to it than that, but that’s it in a nutshell.