Prior to 1913, when the Seventeenth Amendment of the U.S. Constitution was ratified, each Senator was elected by their specific states' legislatures. The idea behind this method of election was to "temper" the popularly elected House of Representatives against the Senate, and to give an equal voice to states, regardless of their populations.

Issues developed over time with the election of members of the Senate. In some cases, state legislatures could not come to an agreement and leave Senate seats vacant, resulting in vacancies that would span a couple years. Another issue was some state legislatures' work would be dominated by Senate elections, to the detriment of local issues. As Senator John Mitchell stated the Senate became the "vital issue" in all legislative campaigns. To change that, some states adopted using "advisory elections" to handle the Senate elections.

Efforts toward reform began in the early part of the 19th century, but it wasn't until the 1890s that the reform movements gained traction. By 1910, 31 state legislatures had passed resolutions to allow for direct election of Senators. By 1912, 33 states had introduced a direct primary for election of Senators. Congress voted to approve what would become the Seventeenth Amendment in 1912 and the measure went to the states, with Connecticut ratifying it on April 8, 1913, the 36th state to do so and allowing for the new amendment to be part of the Constitution.

More Info: en.wikipedia.org