Density doesn't "cause" gravitation, it's simply a factor in determining the intensity of a planet's surface gravity.
Gravitation is a fundamental force felt between all masses. Any mass, even a single particle, exerts an attraction on every other mass around it, and vice-versa. But this is a very, very weak attraction, the weakest by far of the four fundamental interactions in nature, so only a really, really large concentration of mass, such as a star, planet, moon, or asteroid, exerts enough gravitational pull to be significant.
This gravitational force follows an inverse square law -- if you're twice as far away from something, you feel 1/4 the pull, and if you're 10 times as close, you feel 100 times the pull. Also, the mass of a given object behaves as if it's all concentrated at the object's center of mass. The pulls of parts of it in opposite directions from the center of mass cancel out, so the vector of attraction you feel toward an object is straight toward its center of mass, and you feel an acceleration equivalent to what you'd feel if all its mass were concentrated in a single point at the center. The reason you feel weaker gravity on a planet with lower density, therefore, is because that planet has a larger volume relative to its mass, and thus a larger radius. In short, you feel less gravity because you're farther away from the center of mass.
So no, gravity isn't "caused by density." That's confusing the concepts. It's caused by the presence of mass, and the magnitude of attraction between two masses is determined by the distance between them. Density is just a relationship between the mass and size of an object.
A planet's rotation does not generate its gravity. This is a surprisingly common misconception among the general public, and I think it's based on confusion with what we've seen in science fiction movies like 2001
, showing space stations and ships generating "gravity" with rotation or spinning centrifuges -- an effect we experience in everyday life watching clothes spin in the dryer or riding certain carnival rides. But that's not literally gravity. It's an acceleration that creates a sensation of weight, equivalently to how the acceleration caused by the force of gravitation creates weight, but not generated in the same way. And rotational "gravity" pulls outward
from the center, not in toward it. The Earth's rotation actually creates a slight outward (centrifugal) acceleration that cancels a tiny bit of the inward gravitational pull of its mass.
The size and proximity of the Sun has no effect on the amount of gravity/weight you'd feel on the surface of the Earth or Mars or any other planet. This is because planets are in orbit of the Sun, and orbit is free fall. That means that the planet and everything on it is literally falling toward the Sun, being pulled inward by its gravity -- yet is falling sideways
fast enough that it curves around the Sun and never gets closer. Effectively, when you're in orbit, you're spinning fast enough that the outward, centrifugal acceleration is equal to the inward, gravitational acceleration, and they cancel out to zero -- so you don't fall into the thing you're orbiting and you don't feel any weight while you're in orbit.
So it doesn't matter how close you are to the Sun or how big it is; you don't feel its gravity when you orbit it. The only mass whose pull noticeably affects you is the Earth itself.