Well, we really don't know how gravity works, but we definitely know its effects.
Gravity is the attraction to bodies of mass have on one another.
Mass is a measure of how much stuff something contains. Now, the farther away you get from the center of the earth, the less the pull of gravity affects you. In space, you and your space ship are not being pulled very much by earth's gravity because you are far away from its center. However, you both are still being pulled back to earth because gravity is still working on you. You and your ship just happen to be falling back to earth at the same rate, so it just seems like you are weightless and things are floating in space.