The machines formed in cities largely as a result of the waves of immigration to the US in the late nineteenth century; the immigrants were demanding resources far faster than legislation and construction could provide them, and political machines came into being as the charismatic encouraged immigrants to exchange their votes for favors. The power of the bosses was based on their ability to help new immigrants to become established in the U.S.—securing licenses, negotiating rent, helping with naturalization, finding jobs, etc. A boss could have a pothole fixed; he could have someone burn your rival's business and then make sure the fire department never showed up; he could rig an election at any level from ward leader to president (e.g., Matthew Quay and Benjamin Harrison).
The corruption of the political machines, especially Boss Tweed's notorious Tammany Hall in New York City, eventually became too obvious for the middle class to ignore, and by Theodore Roosevelt's time the Progressive Era was established. By the end of World War I, so many immigrants had been socialized that the machines had no real reason to be; nevertheless, some of them lingered as late as the 1960s. Some cities are accused of machine politics even today.
Notable "Bosses" and their political machines