22 has an edge over AK because 22 has already made a pair and AK must improve to beat it. The probability of this happening is a bit less than %50, meaning 22 has a slight edge over AK if the two hands were to get it all in preflop.
22 is ranked much lower than AK because for 3 reasons that I can think of:
- it has a very low showdown value, especially in multi-way pots
- it has a very low chance of improving to a better hand
- Other pocket pairs have a very significant edge over 22
If you were to play 22 in a normal hand, if you don't hit a set you will lose the hand a large majority of the time. This makes it extremely hard to play the hand when facing aggression because you have no showdown equity vs any made hand including pairs.
On the other hand, AK is a hand with a lot more possibilities for made hands (flush if the cards are suited, straights, 2 pairs, top pair top kicker). There are a lot of boards that give AK a very strong hand or a very strong draw. Also, if you make a pair with AK on a dry board, you can almost always be sure that your hand is better than your opponent's.
If you are getting it all-in preflop, 22 is an ok hand to do so with in certain situations (short stacked in a tournament for example). If you choose to get it in with 22, it is important to be aware of the fact that you are flipping with all non-paired hands with no 2 and losing very significantly to all other pocket pairs.
Below are two simulations that show the tightest range an opponent can shove with preflop that would be >50% equity for the caller. The first picture is the tightest range that would result in a favorable call with 22, and the second picture is the tightest range that would result in a favorable call with AK.


As you can see, your opponent has to shove almost 100% of hands for 22 to be a profitable call in the long run, while with AK the opponent can be shoving fairly tight and it would still be a profitable call.
If you are able to play around with flopzilla, you can tighten up the range on the left for 22 and see that the equity in the bottom right drops off very quickly as hands 22 would flip with are removed. Conversely, if you widen the opponent's range with AK you will find that the equity increases fairly quickly, up to 65% against a random hand.
To sum up, it is worse because it has a very hard time improving to a better hand and it is dominated severely against other pocket pairs/made pairs.