Why is general relativity background independent and electromagnetism is background dependent? I read in a book, it is hard to formulate the theory of everything by unifying all the forces, because general relativity is a background independent theory while electromagnetism isn't. Why is this true?
 A: I believe this to be a very important conceptual novelty of GR. Let me explain.
Electromagnetism depends on the background
Consider the action functional for the Maxwell's theory of the electromagnetic field:
$$ S[A] = - \frac{1}{4} \int d^4 x\, \sqrt{-g} F_{\mu \nu} F^{\mu \nu}. $$
This action depends on the electromagnetic potential $A_{\mu}(x)$, as well as on the metric tensor $g_{\mu \nu}(x)$. However, $A_{\mu}(x)$ appears in the square brackets of $S[A]$ and $g_{\mu \nu}(x)$ doesn't.
This actually makes all the difference. We say that $A$ is a dynamical variable, while $g$ is an external parameter, the background. Maxwell's theory is thus dependent on the exact background geometry, which is usually taken to be Minkowski flat spacetime.
Gravity is background independent
Now General Relativity is given by a diffeomorphism-invariant integral
$$ S[g] = \frac{1}{16 \pi G} \intop_{M} d^4 x \sqrt{-g} \,R_{\mu \nu} g^{\mu \nu}. $$
Note the profound difference: now $g$ appears in the square brackets of $S[g]$! Spacetime geometry is a dynamical variable in gravity, just as the electromagnetic field is a dynamical variable in Maxwell's theory.
We no longer have an external background spacetime, because spacetime is dynamical. The (classical) spacetime metric tensor is not given a-priori, but is a solution of Einstein's equations. That's background independence.
Diff invariance vs background independence
These concepts are very different.
Diffeomorphism invariance simply means that we are building a field theory on a spacetime manifold, and any coordinate patch is equally good for describing the theory. Note how both the Maxwell (for electromagnetism) and Einstein-Hilbert (for gravity) actions in this post are written in the diffeomorphism-invariant form.
Background independence is basically whether a theory depends on an external spacetime geometry or not. Maxwell action depends on external background geometry, while Einstein-Hilbert (and its high-energy modifications) doesn't. In simple words, it is about whether $g$ is in the square brackets of $S$.
Why should we care
First, background independent physics is very different from the "old" physics on the background. The absense of the timelike Killing vector field renders generally ill-defined such concepts as time and energy.
Second, there's a physical insight of background independence: space and time aren't some static arena inhabited by fields, but rather have the same dynamical properties that fields have.
Third, there is no place for evolution in external time in the background independent context, because there is no external time. The implications are far-reaching: no general energy conservation (except in particular solutions), no Hamiltonian, no unitarity in the quantum theory. This is known as the problem of time. This doesn't indicate that background independent theories are unphysical, however, just that we have to utilize completely different techniques in order to derive predictions. E.g. the background independent dynamics is described in terms of constraints.
Making electromagnetism background independent
It is really easy to make Maxwell's theory background independent. We just have to couple it to gravity:
$$ S[A,g] = \intop_{\mathcal{M}} d^4 x \sqrt{-g} \left( \frac{1}{16 \pi G} R_{\mu \nu} g^{\mu \nu} - \frac{1}{4} F_{\mu \nu} F^{\mu \nu} \right). $$
Anything coupled to General Relativity (or its high-energy modification) is background independent, because $g$ appears in the square brackets of the total action.
Short conclusion
Electromagnetism is a theory of an (electromagnetic) field in spacetime. Gravity is a theory of spacetime itself.
Why is it really difficult to formulate a ToE
The difficulty in formulating a ToE lies in two completely different issues:


*

*Gravity is hard to consistently quantize. This is partially related to background independence. Manifestly background independent quantization procedures exist, e.g. Loop Quantum Gravity.

*It is hard to establish a natural unification of gravity and Standard Model (unless you believe in compactifications). This has little to do with background independence, mostly being an issue of obtaining a complex gravity+gauge Lagrangian from some simple geometrical model.

A: This is my guess, basically (I self study, have pity).
From the link you gave, the answer is contained in the first paragraph. When dealing with electromagnetic phenomena, the charge and mass of an electron, for example, are free parameters. 
So as we don't have a theory for these parameters, we just have to accept our measurements.
In other words, by the (latest, as I have read a few variations)  definition of background independence, EM is not background independent.
Background independence, a very nice, (and long) answer by Luboš Motl is worth reading, I discovered the link after writing the above.
A: It is useful to keep in mind that there does not seem to be a universally agreed upon definition of background (in)dependence.
My understanding is roughly as follows. 
When we talk about background-independent theories, we mean theories that provide answers to what the space-time (background) should look like. That is, amongst its principles and derivations, the theory would contain something that would determine the geometry or stage on which the objects of the theory "dance." As an example, Einstein's theory of General Relativity does not have to say anything about space-time geometry in its postulates. Instead, the geometry comes out as a consequence of the theory. 
On the other hand, if a theory is background-dependent, then it depends on a postulate about a certain geometry of space. That is, one needs to make these assumptions before he can even begin talking about the theory in question. To be specific, the electrodynamics does not contain enough information to make conclusions about the existing geometry of space(time).
