It would help if you could tell us what you are thinking about here -- what is it that is making the Earth (or the people) be in danger?
In general, I think we would say this sort of thing because from our point of view, the Earth is only important because we humans are on it.
When we say global warming, for example, puts the Earth in danger, of course you are right to say this is wrong. In fact, only people (and some animals and plants) are in danger.
But because we seem like the most important things on Earth, we say that the Earth is in danger whenever we people are in danger.