Polygamy is NOT legal, just practiced in secret........
Furthermore, Mormon polygamy was never legal, at any time - not even in the Utah territory from 1847 to 1890.
Marriage is a legal contract between one man and one woman. There has never been a law enacted to allow otherwise. All the married Mormons who emigrated to Utah in 1847 had been married under the civil laws of their respective states; each one of those states had laws against bigamy, thus making monogamy the "common law."
The very reason Brigham Young chose to move to Utah, rather than Oregon, California, or Texas, as others suggested, was because Utah was an uninhabited "no man's land". However, the area was legally Mexican territory and polygamy was illegal in Mexico.
In the United States, marriage is a legal contract regulated by the various states. When the Mormons went to Utah in 1847, all married Mormons at that time had been married under laws of the states they had come from. Utah became U.S. territory in 1848 after the Mexican War, and thus all citizens living therein became subject to the common laws of the nation, including marriage laws. (To use an analogy, you get your drivers' license from your state, but it is recognized as being legal in all the states. Marriage licenses are similar.)
Once in Utah, Young attempted to establish the "Territory of Deseret," and operate the area as a theocracy, under the "Law of the Lord," which included plural marriage and blood atonement. However, Congress rejected Young's attempt, and in 1850, the area was officially established as Utah Territory, with territorial overseers appointed from Washington D.C.. President Millard Fillmore appointed Young as governor. Thus, polygamy became specifically illegal under U. S. common laws in 1850; but, since polygamy was also illegal under Mexican laws beforehand, there was never a time when polygamy was legal in Utah.