Theymos has detailed how this is actually done. It depends on your id.
...
Currently this randomness is done with a single SQL query, which is very convenient.
update smf_members set ID_POST_GROUP=21 where ID_POST_GROUP=8 and
activity>=775 and activity>=775+conv(substr(sha1(concat(ID_MEMBER,
secretSeed)), 1, 2), 16, 10);
The required activity level per user is suitably random for betting, but anyone who can read my code (there are a few such people) will be able to exactly predict when someone will become Legendary, so I don't really recommend it.