The Secret Service was first established in 1865 as the Secret Service Division of the Department of the Treasury. It was charged with suppressing the rampant counterfeiting of US currency, and presumably doing their work in secret was to be an important part of effectively investigating and prosecuting counterfeiters. While the name hardly seems appropriate today, and hasn't for many years, they are still the agency with primary responsibility for investigations of counterfeiting of US currency and securities and it is also charged with investigating major financial fraud cases. Thought of this way, it makes more sense in that it was the entity that did the work of the Treasury that required secrecy, which generally wouldn't include the foreign espionage and domestic counter-espionage that could have been in its wheelhouse if it had been the Secret Service of the US.
Protecting individuals (the president in particular) is a function they took on after the Assassination of President McKinley in 1901, and this is commonly thought of as its primary activity today. It remained under the Department of the Treasury until 2003 when it was shifted under the umbrella of the Department of Homeland Security.