Originally it was usually written with a 'k', either as 'kawabonga' or 'kowa-bunga'. And for those of you who really do care about these things, it was written that way (and presumably also invented) by Eddie Kean, long-time and super-prolific scriptwriter for the show.

Eventually the kids who had spent hours in front of the TV watching Howdy Doody grew up became older, started surfing, and started using it as a cool thing to yell when cresting a wave. This was helped along by another TV show, Gidget (1965-66), in which the surfers used it regularly. This may be when the current spelling first appeared.

In the 1970s (and on into the 80s, at least) it appeared regularly on Sesame Street, where Cookie Monster would yell it when eating something exciting (usually a large pile of cookies). Sesame Street apparently used the 'k' spelling; Cookie Monster used it in a Letter of the Day sketch as his example of a 'k' word. (When Prairie Dawn claimed that 'kowabunga' was not a word, he told her: "Kowabunga too a word. It esoteric, but it poetic in its own right.")*

60 years, and cowabunga still isn't uncool. Not quite as long a run as cool and OK, but quite respectable for a made-up nonsense word. These days cowabunga has taken over the role of the original Kawagoopa, and is a positive exclamation or battle cry, indicative of unbound exuberance or a devil-may-care attitude.