Some malware use exploits to gain root permissions, as some of the natives services needed for the correct operation of your device and install themselves with the same privileges.
In some cases it is possible to solve the problem with a hard reset to the default settings of your device, but often it's very difficult to get rid of them.