"Mandatory" is presumably related to "mandate" and used when it's a matter of law or regulation.
"Obligatory" is presumably related to "obligation" and used when it's a matter of moral, social or other obligation rather than law. (Like "the obligatory happy ending".)
"Compulsory" seems to mean that you are forced to do something, but the forcing mechanism is unspecified?