The Moon is moving away from the Earth at a rate of 38 millimeters per year. This is cuased by the effects of the tidal bulge here on Earth (the effect is called Tidal Acceleration), which is also causing the Earth’s rotation to slow by 17 microseconds per year.
In about two billion years (life as we know it will have been gone for a little over a billion years and the oceans should just be finished boiling off) the Earth and Moon will reach a state of tidal lock (each will always face the other with the same side) as a secondary effect of spin-orbit resonance. It is believed that this moment of equilibrium will be short lived and the Moon will then reverse course and begin to fall into the Earth’s gravity well; however, by the time collision becomes a threat the Earth and Moon will have long been vaporized by the expansion of Mr. Sun.
The Sun, as a main sequence Population 1 star, will reach its chilling end years as a white dwarf in about 10 billion years. It has, since its birth, been increasing in brilliance and temperature and, negligibly, diameter. It is currently in its midlife of the main sequence and will enter the rapid expansion phase in about 4.5 billion years. In that time the sun, slightly larger, but magnitudes brighter, will expand to a red giant in less than 1 billion years. After approximately another 1 to 2 billion years the sun will shed its outer layers in a series of pulsations during the planetary nebula stage. It will then be left as a hot stellar core, cooling to become a white dwarf.
As far as we are concerned (and I use “we” to represent all living things in the biosphere) the sun will only be useful to us for another 500 million years; it is during this time that we will be able to live much as we do now; however, it will become increasingly difficult to do this as we come closer to that timeframe. By then the luminosity will have increased by 5 -10 percent forcing us to radically change the way we live – living underground or sheltered from direct exposure to the Sun. These “lifestyle changes” won’t suffice for “long” (approximately 400 million years), by that time (900 million years from today) the increase in the Earth’s surface temperature will be high enough to have accelerated the inorganic carbon dioxide cycle to levels lethal to plant life; and that, as they say, is the end of that. A billion years after this the oceans will have just about been boiled away and most of the atmosphere, long hostile to life as we know it, vaporized into space.
The interesting thing to note in all of this is that the timescales are long enough that species inhabiting Mother Earth 500 million years from now will be as radically different as they are from us now to 500 million years ago (the approximate time of the appearance of plant life on the surface of the planet coinciding with the Cambrian explosion). In addition, Andromeda will be nearly a third larger in appearance. Unfortunately, life on Earth will have perished long before the actual “collision” takes place (in approximately 3 billion years) between the Milky Way and Andromeda.