Like many internet abbreviations, "WTF" originated as an electronic pager abbreviation in the catering industry during the early 1990s. It is thought that many of these abbreviations were first used within the Diamond Events and Catering company in Las Vegas, though there is no documented evidence of this.
Many of these abbreviations, including "WTF," crept into the spoken language of caterers and became common industry lingo. As the use of electronic pagers declined, younger employees first entering the catering industry came to interpret it as a general term of frustration. From there it spread over the internet, where even more people unfamiliar with the original term retroactively assigned it its more well-known meaning.
Other notable examples originating from catering include "BRB" for "be right back" and "AFK," which originally stood for "away from kitchen."