The compromise included a range of measures, including the admission of California as a free state, the creation of two territories (Utah and New Mexico) without explicit restrictions on slavery, the creation of a new fugitive slave law that required all citizens to assist in the capture of escaped slaves, and the abolition of the slave trade in the District of Columbia.
There were a number of factors that led to the compromise, including:
The desire to avoid civil war: The issue of slavery was deeply divisive and deeply embedded in America's history, culture, and economy. The compromise sought to find a way to temporarily paper over these divisions and avoid a much bloodier and violent option of a civil war over the issue.
Political expediency: The compromise was also seen as a way for Congress to avoid making a firm decision on the slavery issue. This allowed Southern states to continue their practice of slavery in exchange for the North not forcing the southern states to free them, nor making any more northern territories as slave states.
The economic needs of the country: The compromise allowed for the expansion of territory and economic development in the West, which was important for both Northern and Southern interests.
It's important to note that the Compromise of 1850 was not ultimately successful in resolving the tensions between the North and the South over slavery. In fact, it may have even exacerbated those tensions, and ultimately contributed to the outbreak of the Civil War in 1861.