The "se" makes it passive. Compare
(a) El muchacho le da el libro al niño.
(b) El libro se da al niño.
The second one is passive voice.
In "se le da la gana," as in (b), the subject is "la gana."
What does the passive voice do to the meaning? It makes the person we're talking about seem less proactive, and this has the effect of making the person seem even less caring (more apathetic) than in the non-passive version.
Example
Active: "Solo ayudas a tu mamá cuando te da la gana." (You only help your mother when you feel like it [when inspiration strikes].) Here, the subject of the "gana" clause is some undefined third person subject.
Passive: "Solo haces lo que se te da la gana." (You only do whatever the heck you feel like.) Here, the subject of the "gana" clause is "la gana."
Sadly, although I tried four different dictionaries, I couldn't find this expression. However, linguee.com has at least one solid example of it.