In spiral galaxies, the spiral arms have the shape of approximate logarithmic spirals, a pattern that can be theoretically shown to result from a disturbance in a uniformly rotating mass of stars.
Like the stars, the spiral arms also rotate around the center, but they do so with constant angular velocity. That means that stars pass in and out of spiral arms. The spiral arms are thought to be areas of high density or density waves. As stars move into an arm, they slow down, thus creating a higher density; this is akin to a "wave" of slowdowns moving along a highway full of moving cars.
The arms are visible because the high density facilitates star formation and they therefore harbor many bright and young stars.
Only few galaxies exist by themselves; these are known as field galaxies. Most galaxies are gravitationally bound to a number of other galaxies. Structures containing up to about 50 galaxies are called groups of galaxies, and larger structures containing many thousands of galaxies packed into an area a few megaparsecs across are called clusters. Superclusters are giant collections containing tens of thousands of galaxies, found in clusters, groups and sometimes individually; as far as we can tell the universe is uniform at scales above this.
In 1610, Galileo Galilei used a telescope to study the bright band on the night sky known as the Milky Way and discovered that it was composed of a huge number of faint stars. In a treatise in 1755, Immanuel Kant, drawing on earlier work by Thomas Wright, speculated (correctly) that the galaxy might be a rotating body of a huge number of stars, held together by gravitational forces akin to the solar system but on much larger scales. The resulting disk of stars would be seen as a band on the sky from our perspective inside the disk. Kant also conjectured that some of the nebulae visible in the night sky might be separate galaxies.
Towards the end of the 18th century, Charles Messier compiled a catalog containing the 109 brightest nebulae, later followed by a catalog of 5000 nebulae assembled by William Herschel. In 1845, Lord Rosse constructed a new telescope and was able to distinguish between elliptical and spiral nebulae. He also managed to make out individual point sources in some of these nebulae, lending credence to Kant's earlier conjecture. However, the nebulae were not universally accepted as distant separate galaxies until the matter was settled by Edwin Hubble in the early 1920s using a new telescope. He was able to resolve the outer parts of some spiral nebulae as collections of individual stars and identified some Cepheid variables, thus allowing to estimate the distance to the nebulae: they were far too distant to be part of the Milky Way. In 1936, Hubble produced a classification system for galaxies that is used to this day, the Hubble sequence.
The first attempt to describe the shape of the Milky Way and the position of the Sun within it was carried out by William Herschel in 1785 by carefully counting the number of stars in different regions of the sky. Using a refined approach, Kapteyn in 1920 arrived at the picture of a small (diameter ~15 kiloparsecs) ellipsoid galaxy with the sun close to the center. A different method by Harlow Shapley based on the cataloging of globular clusters lead to a radically different picture: a flat disk with diameter ~70 kiloparsecs and the sun far from the center. Both analyses failed to take into account the absorption of light by interstellar dust present in the galactic plane; once Robert Julius Trumpler had quantified this effect in 1930 by studying open clusters, the present picture of our galaxy as described above emerged.
In 1944, Hendrik van de Hulst predicted microwave radiation at a wave length of 21 centimetres, resulting from interstellar atomic hydrogen gas; this radiation was observed in 1951. This radiation allowed for much improved study of the Galaxy, since it is not affected by dust absorption and its Doppler shift can be used to map the motion of the gas in the Galaxy. These observations led to the postulation of a rotating bar structure in the center of the Galaxy. With improved radio telescopes, hydrogen gas could also be traced in other galaxies. In the 1970s it was realized that the total visible mass of galaxies (from stars and gas) does not properly account for the speed of the rotating gas, thus leading to the postulation of dark matter.
Beginning in the 1990s, the Hubble Space Telescope yielded improved observations. Among other things, it established that the missing dark matter in our galaxy cannot solely consist of inherently faint and small stars. It photographed the Hubble Deep Field, providing evidence for hundreds of billions of galaxies in existence in the visible universe alone.