The church has always had some measure of control over the state government. For most of the nineteenth century, Utah was little more than a theocracy, where religion and government intertwined. Church leaders served as territorial governor, mayors of nearly all towns, on city councils, and they controlled the territorial legislature. Even when the church has not had direct control over the legislature and the government, the government was filled with members of the LDS Church who almost always passed laws the church approved of, or at the very least, would not object to.
Latter-day Saints arrived in Utah in 1847, and by 1848 they had established what they called the territory of Deseret. They formed a territorial legislature and petitioned for statehood. The drive for statehood, which would last until 1896, was less about patriotism or nationalist pride than it was about self-government and self-control. Territorial status put Utah under more control of the federal government than LDS leaders like Brigham Young wanted, whereas statehood would allow for self-government some 2,000 miles away from Washington, DC. The government established by the Mormons was an extension of the Council of Fifty Joseph Smith had established in Nauvoo, Illinois. This secretive body used to have a sort of legendary status among historians of Utah and Mormonism: its records were restricted by the church and little was known about it. Now historians can see those records, and the council was real, though not the nefarious group it was sometimes made out to be. It was largely responsible for organizing the trek west from Nauvoo and it helped establish the territorial legislature and helped govern for a time as a shadow government, though it was soon replaced by the official legislature.
For the first decade, Utah territory functioned fully as a theocracy. Brigham Young, president of the LDS Church, was the territorial governor. But after the Utah War of 1857–58, Young was replaced and federal officials were sent to Utah to oversee the territory. This reined in some of the overt church control of the government, but not completely. Federal judges like James McKean prosecuted church members for polygamy and targeted Brigham Young. But elections were still won outright by LDS leaders and LDS members.
In the 1870s, a combination of dissident Mormons and outsiders, fed up with Young's control of business interests, began to push back. They formed an opposition political party and, with each subsequent election, gained more and more votes until they won a handful of races in the 1880s, especially after Latter-day Saints were disenfranchised under the Edmunds-Tucker Act (1887). But even then, Latter-day Saints still dominated the government, and Utah won statehood in 1896 under a series of complex agreements with the US Congress.
After Utah achieved statehood, the LDS Church was technically separate from the government but was functionally still influential. Since then, the tension between church and state has remained at the forefront of Utah government, where the legislature is always a large majority of Mormons, and the executive branch is usually held by Mormons. While non-Mormons, and in some cases even Mormons, can feel angry or frustrated at the domination of LDS control, the LDS Church can also say that it is not running the government. The line where LDS influence ends, since most government officials are Mormon, is fluid and changing. There have been rare times when the state government has done something the LDS Church has disapproved of, but it is more often the voters who break with the church, perhaps most famously when Utah became the final state to approve the repeal of prohibition, officially enacting the 21st amendment.
The LDS Church today has several lobbyists who push the Utah legislature to enact laws that they support or to try and stop bills they do not like. Despite the church now having millions of members worldwide, it still remains involved in Utah politics and will speak out on issues it supports (lenient immigration policies) or opposes (lenient drug policies or LGBTQ legislation).
For a history of Utah in the nineteenth century, see David Bigler, Forgotten Kingdom: The Mormon Theocracy in the American West, 1847-1896 (Logan: Utah State University Press, 1998), Edward Leo Lyman, Finally Statehood! (Salt Lake City: Signature Books, 2019). For Utah in the 20th century, see Rod Decker, The Elephant in the Room (Salt Lake City: Signature Books, 2019), James B. Allen, Still the Right Place (Salt Lake City: University of Utah Press, 2018), and Charles S. Peterson and Brian Q. Cannon, The Awkward State of Utah: Coming of Age in the Nation, 1896-1945 (Salt Lake City: University of Utah Press, 2015).