A cat lives in a world where smell is vitally important. All creatures within its social group, as well as objects, will be anointed with its unique smell using scent glands in its face, body and tail. When your cat rubs around your legs to greet you it is doing the same as it would in greeting another cat by mutual rubbing of the face and body.
As your face is a little too far away your cat will, for convenience, use your leg. Some cats really try to make the effort and stand on their hind legs to attempt a headbutt on a body part as near to their owner’s face as they can manage. Once you have been suitably rubbed your cat will then take himself off to groom his body and check out your scent.