To elaborate, why the Secret Service? Why not one of the other federal law enforcement agencies, a new agency created for the purpose, or the military?
This is my first post here, so hopefully I'm not doing anything incorrectly.
A little background, following the assassination of McKinley in 1901 Congress passed legislation which formally requested that the US Secret Service's mission to include protection of the POTUS, it has been expanded further and the entire list of protected persons can be found here in United States Code: Title 18, Section 3056. At the time of the Secret Service's inception the only federal law enforcement agencies were the US Park Police, the US Marshals, and what is now known as the US Postal Inspection Service. The Secret Service was created because none of these services had the capacity or manpower to act as an investigative agency.
This excerpt from the Appendix of the Warren Commission Report following the assassination of JFK should answer most of your question:
"This third assassination of a President in a little more than a generation--it was only 36 years since Lincoln had been killed--shook the nation and aroused it to a greater awareness of the uniqueness of the Presidency and the grim hazards that surrounded an incumbent of that Office. The first congressional session after the assassination of McKinley gave more attention to legislation concerning attacks on the President than had any previous Congress but did not pass any measures for the protection of the President.32 Nevertheless, in 1902 the Secret Service, which was then the only Federal general investigative agency of any consequence, assumed full-time responsibility for the safety of the President. Protection of the President now became one of its major permanent functions, and it assigned two men to its original full-time White House detail. Additional agents were provided when the President traveled or went on vacation."
That link for the Appendix of the Warren Commission Report is a pretty good read so if you're interested any further I'd suggest reading it.