Cats are very scent-orientated and they rely on scent marks to recognise territory. Rubbing themselves against people is part of normal cat greeting behaviour, and it is a method of exchanging scents with "friends".
Cats have scent-secreting glands on various parts of their body. And on their head they are on the:
Corners of the mouth
Temples of the head
When a cat rubs itself against our leg we interpret it as a sign that the cat wants attention, and most people will unconsciously respond because of their companion animal-human bond programming and will instinctively reach down to stroke the cat. This reinforces the cats' behaviour because we are then conveying positive touch signals and exchanging our human scents with the cat. The tactile sensation of rubbing against each other, and the exchange of scents between "friends" is all part of the complex behavioural language exhibited by cats - including wild cats - that live in groups. Within a pride of lions individuals will often be observed rubbing their heads against others in the group. Sometimes these physical actions are associated with vocalisation - purring or a meow. Engaging in this interaction with your cat helps to reinforce the bond between you and makes your cat feel reassured about it's position in the family, and more confident about it's role in the household.
The scent marking that cats perform is not limited to "friends" , but extends to inanimate objects as well such as furniture, garden fences, trees and so on. The rubbing (and also urine spraying) in the environment helps the cat to recognise it's own territory, and also other cat scent markings help to warn when it is entering a strange cats territory. - (Health24, May 2011)