Scheinen is intransitive, so there can't be an accusative object.
Dative indicates the receiver or the beneficiary of an action. This is the case here: The children get the light from the sun.
(As a side note, like many verbs scheinen can be turned into a transitive verb by adding the prefix be-. That would be Die Sonne bescheint den Kindern die Köpfe, a somewhat stilted but valid German sentence.)
Auf die Köpfe indicates direction, not position: The sunlight goes from the sun to the heads of the children. That's why it's accusative.
Dative would be auf den Köpfen, not auf der Köpfe. That would mean that the sun is placed on the children's heads, which obviously would be nonsense.