Newton's laws are said to only hold in inertial reference frames. What then are inertial reference frames? These are normally defined as frames in which Newton's laws, such as F = ma, are valid, which is circular reasoning. You can say these are reference frames in which there are no inertial forces, such as linear acceleration, the centrifugal force, or the Coriolis effect. Now, you can modify Newton's laws so they also work in non-inertial reference frames by including terms that correspond to so-called fictitious forces. Linear acceleration is described by mg, so F = ma is modified to F = ma + mg. More complicated terms can be added that correspond to the centrifugal force and the Coriolis effect. Now, the equations can then deal with these effects, but the terms are just added in an ad hoc way, and it doesn't address the underlying question as to what actually causes these effects. You could say that according to Newton's first law, bodies at rest tend to stay at rest, and bodies in motion tend to stay in motion. If you are in a car which suddenly accelerates, your body wants to maintain its previous motion, which was the slower velocity, and so you feel yourself pinned against the seat. If the car suddenly turns a sharp corner, your body wants to maintain its previous motion, which was a straight line, and so you feel yourself thrown to one side of the car. You're prevented from going straight by the fact you are inside the car. If you tie a rock to a string, and spin it around, it's prevented from going straight by the string, and so it goes in a circle. The Moon is prevented from going straight by the gravitational pull of the Earth, and so it goes in a circle, meaning orbit the Earth.
Things prefer to go straight, and if they are prevented from going straight, they try to go as straight as possible, meaning travel in a big circle with gradual curvature rather than a small circle with tight curvature. So often things spinning quickly flatten out if they can. The primordial Solar System and spiral galaxies formed into pancake shapes, and the Earth is slightly flatter at the poles, and bulges at the equator. Newton conducted an experiment where he took a bucket of water, and tied one end of the rope to the handle, and the other end to the ceiling. He rotated the bucket as many times as he could, twisting up the rope, and then released it, so it was spinning on its own. He observed that the water was higher at the edge than in the middle. It's as if the water was trying to get as far as it could from the axis of rotation, so it wouldn’t have to turn as tight a circle. This "trying to get as far as you can from the axis of rotation" is called the centrifugal force.
Now, when you say "objects at rest tend to stay at rest" or "objects in motion tend to stay in motion", the question that arises is "with respect to what?" At rest with respect to what? In motion with respect to what? Newton himself thought the answer was space itself. He thought that space itself formed a frame of reference. He advocated that there existed some sort of universal frame of reference. Einstein showed that there is no preferred reference frame, and that all things are relative, as it were. Even before Einstein, many people were uncomfortable with the idea that empty space itself could serve as a frame of reference. You can't exactly hammer a nail into empty space and measure from that.
An alternative has been suggested by various people throughout history, including Galileo and Newton. It was that distant matter could serve as a frame of reference. In 1863, Ernest Mach (1836 - 1916) published "Die Machanik" in which he formalized this argument. Einstein was greatly influenced by it, and in 1918, he named it "Mach's Principle". This was one of the primary sources of inspiration for Einstein’s theory of General Relativity, although you could say his theory advanced beyond it. Scholars still debate whether Einstein’s theory is truly Machian at a fundamental level. Brans-Dicke Cosmology, where G is replaced by varying scalar field, is an attempt to make general relativity more Machian.
Before Einstein, various people such as Galieo commented on the similarity between inertial forces and gravity. Einstein took this a step further and said that they are in fact the same thing. In Einstein's thought experiments with the elevator, they are indistinguishable. If you were in an elevator that is in free fall, it's the same as if you were in an elevator in deep space. You wouldn't be able to tell the difference. If you were in an elevator that is sitting still on the surface of the Earth, it would be the same as if you were in an elevator on a rocket accelerating at a rate of 1 g. You wouldn't be able to tell the difference. Therefore, acceleration and gravitation are equivalent. Actually, in the free fall case, there is a slight difference. If you were in an elevator in free fall, and you suspended two apples next to each other in the middle of the air, they would slowly get closer together, since their paths, both towards the center of the Earth, converge. These are called tidal effects. However, this small effect would not be observable locally. Ignoring that, the cases are the same. This is called the Weak Equivalence Principle. It states that the effects of inertial fields are the same as gravitational fields, and the absence of inertial fields is the same as the absence of gravitational fields.
The Strong Equivalence Principle takes it a step further, and says that not just the effects of gravity and inertia are the same, but that all laws of physics are the same regardless of whether you are in a gravitational field or a non-inertial reference frame. You can discover how all laws of physics behave in a gravitational field by postulating that their laws in a freely falling inertial frame are identical to the laws in Special Relativity, meaning when there are no gravitational fields.
Now, if gravity and inertia are the same thing, you could say that gravity is really inertia. Even if it looks like you’re going straight, if you are traveling through a gravitational field, that means you’re traveling through curved space-time, which means you’re not really traveling straight, and thus you feel inertial effects, which we call gravity. Another way to describe it is to turn it around, and say that inertia is really gravity. You feel the gravitational attraction of not just nearby matter, like the Earth, but all the matter in the Universe. The Universe is homogeneous and isotropic, which means there is pretty much the same amount of matter in all directions. Thus the gravitational attraction from all of this matter usually cancels out, and you feel no net gravitational attraction. However, if you are in a non-inertial reference frame, then that is no longer true. You feel a net residual gravitational attraction from the rest of the matter in the Universe, which you call inertial effects.
If you are in a car that suddenly accelerates, you feel the effect of being pinned to your seat, or if it turns a sharp corner you feel yourself thrown to one side. In both cases, you feel the effect of acceleration which is a change in the velocity vector. In the first case, it’s changing it’s magnitude. In the second case, it’s changing it’s direction. In what reference frame are you accelerating? You’re motionless with respect to the inside of the car. You could say you’re accelerating with respect to the road beneath the car. However, you would feel the same effect if you were in a spaceship far from any planet. So what reference frame would you choose? The only logical one is the reference frame of the center of mass of all the matter in the observable Universe. Since the vast majority of the matter in the observable Universe is in distant galaxies, you are essentially accelerating with respect to distant galaxies. Now to then say that the effect you feel is literally the gravitational attraction of distant galaxies is more problematic. However, the mere fact that this is the reference frame to use when discussing this subject can’t really be disputed. What other reference frame would you use? With Newton's bucket experiment, the entire bucket was rotating, so the water was motionless with respect to the sides of the bucket. I didn't write this for the purpose of advocating Mach's Principle. It’s just the idea has been tossed around since Galileo, and no one has come up with a better explanation for inertial effects. We still can’t explain it completely. Most people don’t even attempt to explain it. They just add the extra terms to Newton's equations to allow for non-inertial frames, and don’t give it any more thought.
Mach’s Principle remains controversial, although no one suggests an alternative. They just don't like the idea that every day you personally feel the effects of distant galaxies. There are also a lot of ridiculous misconceptions and misinterpretations surrounding it. Some people who say they are against it, are really against some of the absurd versions of it. For instance, some people think Mach’s Principle says that matter interacts instantly with distant galaxies. Of course, that would have been the 19th Century view, such as may have been held by Ernest Mach, but Einstein proved that nothing can go faster than light, so of course that wouldn’t be the modern view. For instance, in the 19th Century, they thought electromagnetic interaction took place instantly due to an electric or magnetic field. Two electrons would instantly feel each other’s presence due to an electric field. Today, we would say the two electrons exchange a virtual photon which causes their interaction. In the 19th Century, they may have thought matter interacted instantly with distant galaxies. Today, we would say that the distant galaxies emitted virtual gravitons that traveled through space for billions of years before being absorbed by the water in Newton’s bucket experiment, or your body when you’re sitting in the car. The reaction of your body to acceleration is due to the interaction between your body and virtual gravitons that were originally admitted billions of years ago by long dead stars in distant galaxies.
Another misinterpretation of Mach’s Principle is that some people think that the property of mass itself is somehow created by interaction with other matter. They think distant galaxies somehow give mass to your body, and if it wasn’t for distant galaxies, you’d be massless like a photon. This is ridiculous. Mach’s Principle doesn’t say anything like that. If you imagine a universe containing only one object, that object would have zero inertia, not because it has no mass, but because there is no other matter in the Universe to gravitationally attract it. According the particle physics, mass is an intrinsic property of massive particles. Particles do not acquire mass as a result of interacting with other matter.
On the Internet, on a sci-physics newsgroup, I once read an absurd statement that said, "If matter gets mass from Higgs particles, then where does that leave Mach’s Principle?" The person who wrote this was profoundly ignorant. First of all, Higgs particles do not give mass to other particles. The interaction between the fermion terms and the Higgs terms in the Lagrangian allow for the existence of fermion masses. This is a good thing because the Standard Model Lagrangian without the Higgs mechanism predicts that fermions are massless. However, it is ridiculous to say that Higgs particles give mass to other particles. Second of all, Mach’s Principle has nothing to do with giving mass to anything. According to particle physics, mass is an intrinsic property of some particles, and they don’t get it from anywhere else. The person who wrote that had no clue what either the Higgs mechanism or Mach’s Principle are, and their statement was utterly ridiculous at several levels simultaneously.