Variation of the atmospheric pressure
By Hydrostatical Law, $p_a = \rho gh$, at a given $h$. However density varies with altitude and with temperature. Temperature varies by altitude. $g$ constant varies with altitude.

That expression is for water, which has more or less constant density, and it is for depth rather than height.
Ynou need to change this to a differential equation. This is fairly easy: $$\frac{dP(h)}{dh} = -\rho g\tag{1}$$
This assumes the atmosphere is in hydrostatic equilibrium: Every layer of the atmosphere bears the weight of all of the mass above the layer.
Another key equation is the ideal gas law, $PV=nRT$. This can be rewritten in terms of local density as $$P = \rho R_s T\tag{2}$$ where $R_s$ is the specific gas constant, the ideal gas constant divided by the mean molecular mass of the gas. Combining equations (1) and (2) yields $$\frac{dP}{dh} = -\frac{g}{R_s T} P\tag{3}$$
Assuming that all of the factors $g$, $R_s$, and $T$ are constant results in an exponential: $$P(h) = P_0 \exp\left(-\frac{g}{R_s T}h\right) = P_0 \exp\left(-\frac{h}{H}\right)\tag{4}$$
where $P_0$ is the pressure at the surface and $H$ is the scale factor height, $H=R_s T / g$.
The exponential atmosphere model assumes constant temperature. This is not a valid assumption. Temperature drops with increasing altitude in the troposphere, rises with increasing altitude in the stratosphere, and drops again with increasing altitude in the mesosphere. Above the mesosphere, the assumptions of a specific gas constant and constant gravitational acceleration also fail.
The assumptions of a specific gas constant and constant gravitational acceleration are approximately valid in the troposphere. An approximate model for temperature in the troposphere is to assume a constant lapse rate $L$: $$T(h) = T_0 - L h\tag{5}$$
where $T_0$ is the temperature at the surface and $L$ is the lapse rate, the rate at which temperature decreases with altitude. Combining equations (3) and (5) results in a solvable first order differential equation, with solution $$P = P_0 \left(1-\frac{L}{T_0}h\right)^{\frac{g}{R_s L}}\tag{6}$$
This still assumes constant gravity and and constant atmospheric composition, and it assumes hydrostatic equilibrium (equation 1) and an ideal gas (equation 2). None of these are even approximately true above the mesosphere.
Increasing accuracy means that atmosphere models become ever more empirical. The models are still tied to physics, but they are also tied to observations. Lower atmosphere weather models have to eliminate the assumptions that pressure, temperature, and atmospheric makeup are functions of elevation only. Upper atmosphere models have to account for variations in solar radiation. One solar flare can make the upper atmosphere expand by over an order of magnitude.