The reason could be that the character was driven by selfish desires or had a misunderstanding of what's right and wrong. Also, external pressures or temptations might have pushed them to behave immorally.
The reason could be that the author wanted to show the complexity of human nature through this character's immoral actions. Or perhaps it's to drive the plot forward and create challenges for the other characters to overcome.