This is one you will hear in physics classrooms and read in physics textbooks. It even seems to be familiar experience. The magnetic repulsion between the like poles of two small bar magnets easily overcomes their mutual gravitational attraction.
But the sun and Earth have magnetic fields too, and their mutual gravitational attraction easily overcomes their magnetic interaction. When Newton derived Kepler’s laws of planetary motion he just needed his law of gravity and did not have to take into account the magnetic and electric fields of the sun and planets.
So it’s not so obvious. Electromagnetism dominates at the atomic and subatomic levels. But on the planetary level it’s the other way around.
The magnetic force results from electric currents that are moving electric charges. It is part of the same phenomenon as static electricity, referred to as electromagnetism. If you are in a reference frame in which a charge is at rest, you see electricity. If you are in a reference frame in which a charge is moving, you see magnetism.
The static electric force between two charged bodies is given by Coulomb’s law, which says that the force between two point charges is proportional to the product of the charges and inversely proportional to the square of the distance between them.
The gravitational force between two particles is given by Newton’s law of gravity, which says that the force between two point masses is proportional to the product of the masses and inversely proportional to the square of the distance between them.
The electric and gravitational force laws are both inverse square laws, so if one computes the ratio of the forces between two bodies, the distances cancel. For the electron and proton, the gravitational force is 39 orders of magnitude weaker than the electrical force. This is the source of the myth that gravity is a much weaker force than electromagnetism.
Why base our estimate of the relative strength of gravity and electromagnetism on these two particular particles? The proton is not even elementary but composed of quarks.
In fact, there is no universal way we can specify the absolute strength of the gravitational force. Newton’s gravitational constant G is not dimensionless and so is not a good measure of the strength of gravity since it depends on what units you use.
The absolute strength of the electromagnetic force is specified by a dimensionless parameter alpha called, for historical reasons, the fine structure constant. It is actually not a constant but varies with energy. However that variation is very gradual and for most practical purposes alpha can be taken to have a value of 1/137.
Conventionally a dimensionless parameter alpha-G is defined to represent the gravitational force strength. It is proportional to the square of the proton mass and has a value 23 orders of magnitude less than alpha. So “officially,” gravity is this much weaker than electromagnetism.
However, as we have already noted, the proton is not even a fundamental particle so it makes no sense to use it to define the strength of gravity. The only natural mass that can be formed from the basic constants of physics is the Planck mass, which is macroscopically large. It is about 22 micrograms, whereas a speck of dust is only about 1 microgram. If you define the dimensionless strength of gravity using the Planck mass you get exactly 1. In the case, gravity is 137 times stronger than electromagnetism.
Gravity is so weak at the atomic and subatomic level because the masses of atoms and subatomic particles are so small. It is strong on the planetary scale because the masses of planets are so large.
However, a good question is: Why are the masses of elementary particles so small compared to the Planck mass? This is a major puzzle called the hierarchy problem that physicists have still not solved. However, it is to be noted that, in the standard model, all elementary particle masses are intrinsically zero and their masses are small corrections resulting from the Higgs mechanism and other processes. The hierarchy problem can be recast to ask why the corrections are not on the order of the Planck mass.
The lack of an absolute strength of gravity does not mean that its strength relative to the other forces is not important. Changing the definition of the strength parameter does not change the ratio of the forces between two bodies in any specific situation. But, the point is, that ratio is not the same in all cases. In fact, it can be almost anything, depending on the masses and charges of the bodies being compared. In short, it makes no sense to even ask what is the relative strength of gravity and electromagnetism.