  We review the theory of the formation of galaxy clusters and discuss their
role as cosmological probes. We begin with the standard cosmological framework
where we discuss the origin of the CDM matter power spectrum and the growth of
density fluctuations in the linear regime. We then summarize the spherical
top-hat model for the nonlinear growth of fluctuations from which scaling
relations and halo statistics are derived. Numerical methods for simulating gas
in galaxy clusters are then overviewed with an emphasis on multiscale
hydrodynamic simulations of cluster ensembles. Results of hydrodynamic AMR
simulations are described which compare cluster internal and statistical
properties as a function of their assumed baryonic processes. Finally, we
compare various methods of measuring cluster masses using X-ray and the thermal
Sunyaev-Zeldovich effect (SZE). We find that SZE offers great promise for
precision measurements in raw samples of high-z clusters.
