Both the airfoil shape and inherent properties of the air contribute to the stall angle of attack. You asked for a theoretical background, but I will list the factors that influence stall because there is no simple formula for it.
The most important factor is the suction peak which develops right behind the stagnation point on the upper side of the leading edge. High suction means high speed and that in turn means high friction, so the air loses energy which it needs further downstream to regain its pressure. If too much energy is lost, the flow separates. Enough separation and lift suffers, so here you have the most immediate reason for a stall.
What can be done to shift that point to a higher angle of attack?
- Pitch up faster. That way, the flow over the rear part of the wing has a boundary layer from lower angles of attack and will not separate when the leading edge passes through the angle of attack at wich it stalls in normal conditions. This can shift the stall angle of attack up by 50%. But that works only temporarily and the same mechanism will delay recovery once the stall has occurred.
- Increase the leading edge radius. This spreads out the suction peak and makes it less pointy. A blunt leading edge is especially helpful with higher wing loadings when Mach effects play into the stall angle of attack mechanics. Once the local suction peak at the nose of an airfoil reaches a local Mach number of slightly less than 1.6, no lift increase could be observed in experiments.
- Increase wing camber, either by nose and/or trailing edge flaps or by cambering the airfoil. This helps to reach high lift coefficients already at low angles of attack, and especially nose devices (slats, Krüger flaps) shift the stall angle of attack up as well.
- Use a well-designed airfoil with a long laminar run and a Stratford pressure distribution past the turbulent transition point on the upper side. This helps to reduce boundary layer losses and maximizes energy reserves for the steepest possible pressure rise. But you need a clean, smooth and well built wing for that to really happen. And the right Reynolds number range: Gliders use this effect extensively but airliners cannot use it at all.
- Increase wing loading. This will shift the stall speed to a higher Reynolds number where friction losses are smaller relative to the inertial energy of the air. Of course this will increase stall speed, but is will also shift the stall angle of attack higher. A bit.
- Increase wing chord (while maintaining the same area). This has actually two effects: The smaller one is again from the increase in Reynolds number, but the more powerful is from the reduction of the wing's aspect ratio. At a smaller aspect ratio the lift curve slope is flatter, so the same lift coefficient (and suction peak) is reached at a higher angle of attack.
- Increase wing sweep. The pressure changes over the wing are now proportional to the cosine of the sweep angle, so all effects are shifted to higher angles of attack accordingly. But beware of a combination of high sweep and high aspect ratio: Stall will become outright nasty. If you combine 6 and 7, you will at some point arrive at a delta wing which flies well even with fully separated upper side flow (vortex lift). Now your limit angle of attack will be defined either by the vortex bursting or loss of directional stability.
- Fly in hotter, less dense air. This also helps to increase the Reynolds number because you need to move faster for the same dynamic pressure. However, much of that advantage is eaten up by the increase of the air's viscosity with temperature.