This question already has an answer here:
- When to use “cannot” versus “can't”? 1 answer
Is "Why can not I" grammatically correct?
If not, why is "Why can't I" grammatically correct?
They are both correct. The first is a contracted form of the second. The first seems to be common in spoken and even written English, which makes the second a bit unheard of.
'Why can not I' is not grammatically correct. Because as per the standard formal usage, in interrogative sentences only the helping verb can come before the subject and not 'not.'
In 'Why can't I,' can't is read as cant and not 'can not.' While 'can not' consists of two words, can't is just one word and it IS the helping verb here. It's the word taken into writing after it became popular in speaking.