There was once a logic to it, based on a mix of "regional" codes for civilian ones, and "type" for military ones.
The "hub" of each civilian group had the "two letters" version - AA for Belfast, BB for BBrum, CC for that place I don't fly to, LL for LLunnun, FF for cardiFF, KK for gatwiKK etc. The satellite fields then started at xA and worked up.
T was FIRs and such, and airfields that didn't fit the system.
E is new, and is the Scottish islands (mostly).
I think the pattern got lost as codes were allocated "on request" - hence Sx is Stansted and East Anglia, except for Sheff City that wanted EGSC.
Bit esoteric, really.