Why is it dative in the sentence "Das macht mir Spaß" and "Macht es dir Spaß"? What is acting on what in these two sentences?
According to this online resource:
[The Dative] Case [is] used to express direction towards an indirect object, the receiver, and is generally indicated in English by to or for with the objective case.
The unspecified subject es in your sentence is providing fun (accusative) to me (dative). As I, sort of, receive having fun, I am put in the dative case.
For comparison a (grammatically) similar sentence (subject, predicate, indirect object (dative), direct object (accusative)):
Er gibt mir einen Apfel.
"Das" and "es" depend on the context: they refer the ongoing activity, whatever you're doing at the time or enjoying (e.g., watching). Compare it to "it (the play) amuses me".
"Viel Spaß beim Fußball[spiel]!" would be "have a lot of fun at the soccer game", no matter if you're playing or just watching.
I'm not used to grammar terms, so I will show some examples.
Wem macht es Spaß? Das macht mir Spaß. Macht es Dir Spaß?
What actually is fun is not mentioned in the sentences. Es and das refer to something mentioned in the sentence before or something that is actually happening.
Added (Trying to make it clearer)
Because the dativ case is nearly lost in the English language, it's a bit difficult to show good examples. Normally I would say "Do you have fun?", translating this to German you will get "Hast Du Spaß?". Trying to translate "Macht es Dir Spaß?" to English, I would say "Does it make fun to you?"
The difference between "Macht es Dir Spaß?" and "Macht es Dich glücklich?" is that "Spaß" is a thing by itself while "glücklich" is the state of another thing. You have fun, but you are happy.