Clarification: Given that a string literal can be rewritten as a const
char[]
(see below), imposing a lower max length on literals than on
It's not that 509 characters is the limit for a string, it's the minimum required for ANSI compatibility, as explained here.
I think that the makers of the standard pulled the number 509 out of their ass, but unless we get some official documentation from this, there is no way for us to know.
As far as how many characters can actually be in a string literal, that is compiler-dependent.
Here are some examples:
String literal of length 100000 exceeds maximum length 509 that C90 compilers are required to support