Can software itself be encrypted?
If you want a practical answer: with Intel SGX, the answer seems to be a qualified yes, but software development is likely to be more painful.  (Similar with a TPM, though that will be even more annoying.)  See, e.g., https://security.stackexchange.com/q/2459/971.

If you want a theoretical answer: in theory, you could use various cryptographic schemes for outsourcing computation (e.g., fully homomorphic cryptography, secure multiparty computation, SNARKs, outsourcing computation, and so on).  As a general theorem, any computation you can do in polynomial time, could also be done on the remote server in polynomial time, with ability to verify that the result it gives you back is correct in polynomial time.  However, in practice right now these schemes include an enormous performance overhead (a factor of a million slowdown or more), except for certain special tasks, so they're not at a stage where you could actually use them in practice today.