Several theories exist to explain galactic spiral structure, but the dominant theory is that the spiral structure is a stable density wave propagating through the disk of the galaxy.
The characteristics of the spiral arms that point to a density wave interpretation are the strong symmetric organization of two arms in Sd galaxies, the existence of the arms despite the strong differential rotation that must occur for stars orbiting at a constant velocity, which would wind-up features tied directly to the motion of the stars, and the appearance of the spiral arms in both blue and red color bands, which says that the arms are present not only in the short-lived young stars, but also in the long-lived old stars.
Density wave, of course, are common in physics. Sound waves are the best-known example of a density wave. Among astrophysical disks, density waves are common in the rings of Saturn. These examples, however, have some important differences from the density waves one would find in a galactic disk. With sound, the local pressure determines the characteristics of the density wave; with the rings of Saturn, the resonant forcing by the moons of Saturn, particularly by the moon Mimas, determine the wave's characteristics; but in the galactic plane, the self-gravitation of the disk, the differential rotation of the disk, and the action of the galaxy's spheroid determine the characteristics of the waves.
If the spiral arms are density waves, what characteristic of the stellar orbital motion are they tied to? They cannot be directly tied to the orbital motion because of the strong differential rotation of the galactic disk, which would rapidly destroy the wave structure; they can, on the other hand, be tied to the drift of a star's maximum distance from the galactic center. As a star orbits around another much more massive object, it moves in distance between a maximum and a minimum distance. For a star orbiting a central object, such as another star, the orbit is an ellipse, so that the orbit is closed, and the maximum distance is separated from the minimum distance in the orbit by 180°. When a star is orbiting within a galaxy, however, the orbit deviates from a ellipse , because the surrounding stars modify the gravitational potential. A stellar orbit in the galactic plane is not closed, and the position of the orbital minimum occurs at an angle less than 180° from the orbital maximum. The orbit, in fact, looks very much like a drawing produced by an off-center pen attached to a wheel traveling around the inside of a circle. The nearly fixed spiral pattern we see is a consequence of the drift of the orbit maximum for the stars within the disk. If we select a coordinate system that is rotating at the correct rate, we will find that the stellar orbits are nearly closed, with their maxima separated from their minima by 90°. There will be a slight drift of maxima and minima, with the rate of drift dependent on the radius from the galactic center, but it will be weak enough that a gravity wave will persist with a nearly fixed pattern. It is the symmetry within the rotating coordinate system that explains the existence of two arms in spiral galaxies.
While the orbital dynamics explain the reason why strong spiral arms appear as pairs in many galaxies, and it explains the persistence of the spiral pattern, it does not explain the origin of the density wave. The wave itself arises through an amplification and feedback mechanism. The amplification arises from the slight radius-dependent drift in the orbital maxima. As the drift converts a leading density wave, a wave with the outer part leading the inner part, into a trailing density wave, the density wave is intensified. The feedback is from the propagation of a trailing wave through the galactic center; as the wave passes through the center, it becomes a leading wave. These mechanisms create the global structure that is seen, and the amplification mechanism explains why most spiral arms are trailing rather than leading.