"On the morning of September 11, 2001, nearly 3,000 people were killed in a series of coordinated terrorist attacks in New York, Pennsylvania and Virginia," the TSA summarizes in its official history. "The attacks resulted in the creation of the Transportation Security Administration, designed to prevent similar attacks in the future."
The TSA launched with the passage of the Aviation and Transportation and Security Act on November 19, 2001. The new law nationalized passenger screening, which previously had been the responsibility of airlines. It's not clear why anybody saw a need for the TSA, since it's unlikely that a federal agency would have been any more successful than private contractors at predicting terrorists' unprecedented use of aircraft as kamikaze weapons. It's especially unlikely that the federal agency we actually got would have successfully diverted itself from confiscating play-doh to thwarting homicidal fanatics.