If you're asking about Dependency Injection, you should read this
To summarize Dependency injection, it is a pattern for shifting around type dependencies. Instead of having your dependencies directly in your application classes, you move them to a component that manages them. This component is usually known as an Inversion of Control container, and that's what Spring provides primarily. You can do this with XML or you can do it with Java. In other words, though you are shifting the dependencies, they can be defined at run-time (with XML) or at compile-time (with Java).
If you're asking about why to configure your context with XML vs Java, then one of the answers is that you don't have to recompile your source code to change configurations if you're using XML. chrylis also brings up some good points. XML is not type safe (but I've never had a problem with that).
However, there are some configurations that are hard to do with XML. The XML schemas that Spring declares are restrictive and force you to use some coding conventions. With Java configuration, you don't have those restrictions. You can create your objects any way you want.