Generally, people use can't in speech and informal writing, and cannot or can not in formal writing or very formal speech. Also (as @Kris points out in a comment), cannot might be used when you need to carefully distinguish it from can't in speech.
differences - When to use "cannot" versus "can't"? - English Language ...
The phrase "can not" may mean "cannot" or "can't," but it also may mean "able not to," which is much different than "not able to" as it conveys the ability to not do something rather than the inability to do it.
Why is “cannot” spelled as one word whereas other similar constructions such as “do not,” “will not,” “shall not,” “may not” and “must not” are spelled as two words (unless they are contracted as “...
Why is “cannot” spelled as one word? - English Language & Usage ...
As does Thesaurus.com: The terms cannot and can not are identical in meaning and are typically considered to be alternate forms of one another. However, the form cannot is much more commonly used than can not. Cannot has become the standard form in formal writing (and is typically the form recommended by most grammar resources and style guides).
5 OED-cannot definition: the ordinary modern way of writing can not Both cannot and can not are acceptable spellings. There’s no difference in meaning between cannot and can not. but the cannot is much more usual. Some references from ELU - can't vs cannot Why is “cannot” spelled as one word?.. (a few exceptions)
Cannot is the only negative form that contains not rather than -n't. Theoretically, since it is a single word, you can say why cannot you... without a problem. My theory is that modern English speakers don't want to put cannot before the subject because it contains not and sounds like can not.