Initially, it aimed at replacing C++ (which it mostly achieved, for LOB apps). The primary market for Sun has always been the enterprise, so it was a natural target.
Then, when the web exploded, people found out that developing against a virtual machine could be safer and more predictable than developing against the operating system, so web-app servers were born. J2EE provided a certain degree of consistency, which other platforms did not have.
As platforms evolved, they tried to generalise their use-cases, which introduced a number of abstractions and forced decoupling; and because Java2 lacked support for a lot of introspection/metaprogramming features, you had to explicitly cover a lot of cases, leading to interfaces multiplying.
It didn't help that at the time, the "Pattern" movement was popularised and their tools (which are all about decoupling and introducing further levels of abstractions) became overused.
I remember (vaguely) the beginnings of Java, but not how it did end up in Enterprise and why it was loved so much there.