I too have wondered this in the past, and an official explanation has been completely lacking in my research! However, the closest I've found is the suggestion that it's for drainage. The following link of a podcast transcription states the following:
Richard Merritt, a landing support manager with United Space Alliance, says Florida's marshy terrain is the main reason it took nearly a decade to move from one coast to another.
Richard Merritt/Landing Support Manager: We were still a research and development type of aircraft/spacecraft. They just weren't comfortable with the target here. If you look from above and looking on the runway, each side has a lot of water. So, if you didn't make the runway here, you'd be talking to the alligators.
They go on to talk about how it was easier to land on a dry desert (another landing site) because you didn't have to worry about that - so I think that hints that the canal was probably constructed for drainage purposes to keep the runway from being swamped.
There are other theories that have been put forward, but none seem plausible to me:
- The most popular seems to be water needed if a fire should break out - but digging a water filled trench all the way around the runway is an incredibly archaic way to do this, especially when multiple fire hydrants would have been far cheaper to construct and this facility is only found at this runway! In addition, since the shuttle isn't carrying much fuel at all on landing, the chance of a massive fire requiring this much water is rather low.
- Again, security is another theory, but NASA doesn't use this approach anywhere else, and again it's incredibly archaic - we have much better, and cheaper ways of securing facilities these days.
- Material needed to level the runway is another theory, but if this was the only reason then it would have likely all come from one big hole rather than digging a neat trench around the runway.
- If it was needed to catch debris that might blow onto the runway, then we'd see structures with similar purposes in other locations, which we don't. If this was the case, then a simple reinforced fence would have done the job arguably more effectively for a fraction of the cost.