We develop a model for the cosmological role of mergers in the evolution of starbursts, quasars, and spheroidal galaxies. By combining theoretically well-constrained halo and subhalo mass functions as a function of redshift and environment with empirical halo occupation models, we can estimate where galaxies of given properties live at a particular epoch. This allows us to calculate, in an a priori cosmological manner, where major galaxy-galaxy mergers occur and what kinds of galaxies merge, at all redshifts. We compare this with the observed mass functions, clustering, fractions as a function of halo and galaxy mass, and small-scale environments of mergers, and we show that this approach yields robust estimates in good agreement with observations and can be extended to predict detailed properties of mergers. Making the simple Ansatz that major, gas-rich mergers cause quasar activity (but not strictly assuming they are the only triggering mechanism), we demonstrate that this model naturally reproduces the observed rise and fall of the quasar luminosity density at -->z = 0–6, as well as quasar luminosity functions, fractions, host galaxy colors, and clustering as a function of redshift and luminosity. The recent observed excess of quasar clustering on small scales at -->z ~ 0.2–2.5 is a natural prediction of our model, as mergers will preferentially occur in regions with excess small-scale galaxy overdensities. In fact, we demonstrate that quasar environments at all observed redshifts correspond closely to the empirically determined small group scale, where major mergers of ~L* gas-rich galaxies will be most efficient. We contrast this with a secular model in which quasar activity is driven by bars or other disk instabilities, and we show that, while these modes of fueling probably dominate the high Eddington ratio population at Seyfert luminosities (significant at -->z = 0), the constraints from quasar clustering, observed pseudobulge populations, and disk mass functions suggest that they are a small contributor to the -->z 1 quasar luminosity density, which is dominated by massive BHs in predominantly classical spheroids formed in mergers. Similarly, low-luminosity Seyferts do not show a clustering excess on small scales, in agreement with the natural prediction of secular models, but bright quasars at all redshifts do so. We also compare recent observations of the colors of quasar host galaxies and show that these correspond to the colors of recent merger remnants, in the transition region between the blue cloud and the red sequence, and are distinct from the colors of systems with observed bars or strong disk instabilities. Even the most extreme secular models, in which all bulge (and therefore BH) formation proceeds via disk instability, are forced to assume that this instability acts before the (dynamically inevitable) mergers, and therefore predict a history for the quasar luminosity density that is shifted to earlier times, in disagreement with observations. Our model provides a powerful means to predict the abundance and nature of mergers and to contrast cosmologically motivated predictions of merger products such as starbursts and active galactic nuclei.