how does earth's atmosphere work