Some background from the FBI website:
By 1907, the Department of Justice most frequently called upon Secret Service "operatives" to conduct investigations. These men were well-trained, dedicated -- and expensive. Moreover, they reported not to the Attorney General, but to the Chief of the Secret Service. This situation frustrated Bonaparte, who wanted complete control of investigations under his jurisdiction. Congress provided the impetus for Bonaparte to acquire his own force. On May 27, 1908, it enacted a law preventing the Department of Justice from engaging Secret Service operatives.
The following month, Attorney General Bonaparte appointed a force of Special Agents within the Department of Justice. Accordingly, ten former Secret Service employees and a number of Department of Justice peonage (i.e., compulsory servitude) investigators became Special Agents of the Department of Justice. On July 26, 1908, Bonaparte ordered them to report to Chief Examiner Stanley W. Finch. This action is celebrated as the beginning of the FBI.
J. Edgar Hoover entered the picture in 1924:
For the new Attorney General, Coolidge appointed attorney Harlan Fiske Stone. Stone then, on May 10, 1924, selected Hoover to head the Bureau of Investigation.