What causes the Earth to have gravity?
Any massive body (i.e., a body having mass) like the stars, planets, moons, and any atom in the universe have, what is called, a gravitational potential which results in its gravity.  This is described by Newton's Law of Gravity. Why masses cause gravity, we do not know.  

So, in short, the earth's mass causes it to have gravity.