Both forms have been in use since at least the 15th century, and both forms are acceptable today, although it appears* that cannot is far more common. Oxford Dictionaries offers this comment:
Both the one-word form cannot and the two-word form can not are acceptable, but cannot is more common (in the Oxford English Corpus, three times as common). The two-word form is better only in a construction in which not is part of a set phrase, such as ‘not only ... but (also)’: Paul can not only sing well, he also paints brilliantly.
I see no good reason for preferring one over the other. If you search the internet you will find that many people have bad reasons, some of them quite funny. Oxford's rule of thumb seems as reasonable as any, and more reasonable than most.
For what it's worth, my own wholly irrational practise is to discriminate by stress pattern (with cannot as a trochee ¯ ˘ and can not as a spondee ¯ ¯) and use whichever provides the reading my context demands.
* I have been unable to confirm this in corpora readily available to me. Google Ngrams refuses to distinguish the terms; and as reported from the BYU interface at http://corpus.byu.edu/, COCA prefers can not by more than 1,000 to 1, which cannot (or can not) be credited, while BNC does not acknowledge the existence of cannot at all.