Madara probably used reverse talk no jutsu to convince him to do evil - and corrupt him to his current extent; similar to what he did to Sasuke - but more radical.
Providing that this is Obito. We dont know - only that thats his body - not his soul, or whether or not he is in control of his body.