Why do all planets revolve around the sun?

All do not. There have been planets that revolve around other stars.

And if you examine it closely, Earth and Moon are revolving a centerofgravity point between the two, and it is this centerofgravity point which is rotating about the sun.

So, why? Well Newtons First and second Law of motion, and Newtons Law of Gravitational attraction describe both reasons to your question why.

Think about it.