The question is extremely broad and ambiguous, and should be made more precise if you wish a more meaningful answer. For example, your two questions differ: do you mean why do we live on earth rather than on another planet? Or why is earth habitable to life? The answer to that belongs to astronomy and biology. Do you mean why do this collection of molecules manage to get together and reproduce in a way to locally reverse entropy? This belongs to evolutionary theory and biochemistry. And who is "we"? All living beings on earth, or all humans? Or do you mean why are we conscious? This is an unanswered question, but a few hints come from neurobiology. Or are you looking for a metaphysical purpose? There science does not go, and so your answer might come from religion, or might come up with there not being one. Are you looking for an artificial purpose that is not religious? Try existentialism. But above all, make your question more precise. Then you will find that the question has been posed lots of times, and there are lots of answers out there.