Not magnetism, it's gravity. I'm not so sure that magnetism without gravity would do a very good job keeping stuff in orbit. Spacecraft in orbit about the Earth or Moon has no magnetism to speak of, so, that's not it.
Gravity is what allows every particle in the universe to attract to every other particle. Orbits are sorta the fight between inertia and gravity. Without gravity, the Moon would just want to keep going in a straight line forever (Newton's first law). Without inertia, the gravity would cause the Moon to crash into the Earth thus ending us (Newton's second and third laws). As the Moon goes mostly sideways about a kilometer every second, the Earth's gravity is trying to pull the Moon into itself. OK, if it was perfectly balanced, the Moon's orbit would be circular, but, it's close enough to perfect that the Moon's orbit is slightly eccentric. At its closest point it's moving just a wee bit too fast to keep it circular at about 362,600 kilometers from the Earth-Moon baricenter, so, it starts to move slowly away and slows down a bit. When it gets too slow to keep it in a circular orbit about 405,400 kilometers away, it begins to 'fall' toward the Earth. This cycle keeps it in an elliptical orbit.
(
https://en.wikipedia.org/wiki/Newton's_laws_of_motion)
Johannes Kepler figured out three laws concerning orbital mechanics (
https://en.wikipedia.org/wiki/Kepler's_laws_of_planetary_motion).
Of course, this scenario isn't perfect as the Sun and other planets and all the other stuff in the universe acts gravitationally on the Earth and Moon, so, the Moon's orbit varies a bit. This works the same was between the Sun and the Earth-Moon system, but, at about 18½ kilometers per second, and somewhere around 149 million kilometers from the Sun.
Yes, gravity and the revolution of the Moon causes tides. But, it affects land and sea. The land doesn't slosh around like the sea, but, it does move up and down, maybe a few inches or so. but, the sea follows the Moon. The side facing the Moon (or actually slightly behind it) is pulled up a few feet or so because the Moon pulls on it. Now, imagine you have a bucket of water on a rope and you swing it fast enough with your arm in a circle up and down, the water stays in the bucket and doesn't fall out, it's pushed to the outside of the circle. So, the side of the sea away from the Moon also rises up because of this (because the earth also revolves around this baricenter), hence two tides per day on most of the oceans. This varies considerably because of the shape and locations of the land masses, the water can't move freely. The Earth also causes tides on the Moon, but, since it's a big rock, the tide is very tiny. But, over time Earth's gravity has caused the Moon's diameter to elongate to some extent in the axis pointing sorta to and away from the Earth.