I know that the reason why they stay in orbit but why do some move away from the earth(the moon) or come closer and eventually fall? And why does the moon move away from earth?
Objects can be in a stable orbit around the earth if the only force acting on them would be earth's gravity. Often other factors influence the objects and they either fall or use small rocket thruster to stay in a particular orbit.
What happens for example with satellites is that they experience atmospheric drag which slows them down. The atmosphere hundreds of kilometers above ground contains only a few molecules per cubic meter but this is already enough to have an effect. Other possible causes for falling or leaving the orbit is gravity from other sources that are nearby, magnetic fields, particles from the sun, etc.