Kittens are very attached to humans, especially the first person they meet who is kind to them; they will consider that person as one of their own kind. Sleeping with a person is probably out of a need for them, as sleeping in a cardboard box would be cold, uncomfortable, and lonely. 
Cats are naturally insecure around humans and will avoid people they don't know or trust. If your cat dares to sleep next to your pillow, it means it trusts you completely and has already accepted you as its owner.
When a cat likes to sleep next to its owner, it means that it trusts its owner not to hurt it and that the owner can provide it with a sense of security. This is a sign that the cat has recognized its owner.