Prior to the 1820s, there was little in the way of organized labor in the modern sense, and collective bargaining was usually found to be illegal in courts. Further, non-property holding white males couldn't vote in most states until the mid 1820s so parties had little interest in chasing after the mostly non-existent votes of wage-earners.
As the number of wage earners rapidly increased, labor unions began to form. David Montgomery, in Wage Labor, Bondage, and Citizenship in Nineteenth-Century America observes that
the Jeffersonian conviction that people best solved their problems by
forming their own associations encouraged an exuberant diversity in
civil society and provided workers with a widely recognized
justification for assembling in trade unions, short-hour leagues,
cooperatives, workingmen's parties, working-girls' clubs, and ethnic
self-help societies, parishes, gymnastic associations, singing
societies, and nationalist clubs. Workers used both their claims on
government and their rights to act without interference from
government in their battle against the inequities of the labor market.
Within a few years of the setting up of the first labor unions in the 1820s, they started getting involved in politics, forming labor parties which had some minor successes at the local level. This didn't last, though, as
disagreements regarding programs of reform soon broke out between
different groups, the established parties made strong efforts to wean
away labor support and the labor political movement waned in strength
as rapidly as it had risen. By 1832 it was thoroughly disorganized.
Labor became closely associated with Jacksonian Democracy following the split in the Democratic-Republican Party. Remnants, including labor union leaders, of the short-lived Working Men's Party (1829-31) joined the Locofocos (formed 1835), a faction of the Democratic Party. This faction was also short-lived (until the mid 1840s), and the economic climate worked against organized labor:
In 1837...there came a disastrous financial panic, followed by a
severe depression. The unions were powerless to resist economic
forces' and dissolved almost over night.
For the next 25 years business depression and industrial
disorganization were almost uninterrupted. Under the circumstances the
ordinary trade union methods held little promise of success. Again the
militant spirits among the workingmen turned to politics and to
various communistic experiments.
With voter-participation rising sharply from the mid 1820s and reaching new heights in 1840,
male wage earners were mustered into election campaigns and public
spectacles by the Democrats, Whigs, Know Nothings, and Republicans,
not to mention the many labor-reform parties.
The fortunes of labor unions continued to fluctuate. Then, in 1866, the National Labor Union was formed with no clear affiliation to any political party, excepting its 'adjunct', the Colored National Labor Union which supported the Republican Party.
In 1872 the union formed the National Labor and Reform Party, but did
not muster sufficient strength to take part in the national election
of that year. The leaders soon allied themselves with the Greenback
party....Greenback-labor parties were organized everywhere and in the congressional election of 1878 about l,000,000 votes were cast for their candidates. This was the high., tide of the movement. The Greenback presidential candidate in 1880” polled only about 300,000 votes and in 1884 the Greenback vote dropped to 175,000.
As the Greenback party faded (it was eventually dissolved in 1889), a new labor federation emerged, the Knights of Labor which associated itself with Henry George and the United Labor party in opposition to both Republicans and Democrats in the 1886 election for mayor of New York City. Formed in 1869, it didn't peak until the mid 1880s but was then rapidly overtaken by the American Federation of Labor, formed in 1886. In the American Federation of Labor,
emphasis was placed upon the non-political functions of the A. F. of
L. at the beginning of its career. In the manifesto of the second
convention it was stated that the Federation “looks to the
organization of the working classes as workers, and not as…politicians..."
It was not until well after the Civil War, in the 1890s, that labor began to look to the Democratic party as an ally in restricting immigration; the ready availability of cheap labor was favoured in particular by northern industrialists who were associated with the Republican party.