Barry Popik, in "Entry from May 09, 2016", mentions the joke is in the 19 January 1986, Chicago (IL) Tribune.
I observe an appearance of the joke in The Central New Jersey Home News (New Brunswick, New Jersey) of 11 May 1985 (paywalled):
The Home News SILLY SQUARE
…
Q: Why was 6 afraid of 7?
A: Because 7 ate 9 and 10.
…

The joke is unattributed, so, at least until further evidence is found, the origin is unknown, sometime prior to 11 May 1985.
As I'm of a certain age, I tend to blame all jokes like this on the anonymous geniuses at Dixie Cup Corporation, who produced a line of riddle cups in the 1970s, and again in the 1990s. So far, I haven't been able to verify that the onus belongs with them. That I also blame the "Why do mice have such small balls?" joke on the same source, however, may argue against my speculation.