Cats have scent glands in their cheeks and chins. When they rub against you, they are depositing their scent on you.
Cats also rub against people as a way of showing affection. This is especially true if they rub against your face or legs.
They are transferring their scent from their scent glands to you, which helps to keep them clean and protected from parasites.
Sometimes, cats rub against people simply to get attention. If you ignore them, they may rub against you more and more until you give them the attention they crave.
Rubbing against people can also be a way for cats to relieve stress. When cats are feeling stressed, they may rub against people or objects as a way to calm themselves down.
Cats with hyperthyroidism may rub against people more often due to the increased metabolism associated with the condition.
For example, Siamese cats are known for their affectionate nature and they are more likely to rub against people than other breeds.