Clusters of galaxies are studied from a theoretical point of view, comparing with observational results whenever possible. The problem is approached both analytically as well as by means of high-resoultion numerical simulations. The dark matter halo, the hot intracluster gas, and the stellar component are investigated separately. Numerical clusters are consistent with a relatively simple scenario, in which these objects form around local maxima of the primordial density field, smoothed on Mpc sacales. Hot diffuse gas is in approximate hydrostatic equilibrium with the dark matter potential, and it is well described by a polytropic equation of state. Global X-ray properties are closely interrelated, and deviations from self-similarity are expected even when radiative processes are not considered. Star formation is severely reduced in the inner regions of clusters, due to the fact that infalling galaxies loose their hot gas reservoirs during the first orbit.