There are plenty of exceptions, but in general, the nominative is used when something is the subject of a sentence, and the dative is used when something is the indirect object of a sentence.

He...