Hansen was born in Tetonia, Idaho. He graduated from Ricks College (now Brigham Young University-Idaho) in 1956 and did graduate work at Idaho State University. Hansen served in the United States Air Force from 1951 to 1954 and the United States Naval Reserve from 1964 to 1970.
Hansen moved to Alameda, Idaho, and was established as a life insurance salesman by 1958. He was elected mayor of Alameda in 1961 and supported its merger with Pocatello the following year. Following the merger Hansen served as a Pocatello city commissioner until 1965.
Hansen was an unsuccessful candidate for United States Senate in 1962 but won a seat in the House two years later. He again ran for the Senate in 1968 but lost to Democratic incumbent Frank Church. Hansen ran a third unsuccessful Senate campaign in 1972.
In 1975 Hansen returned to the House. In Washington Hansen was known as one of the most conservative members of Congress. He was a particularly vocal critic of the Internal Revenue Service.
Hansen took it upon himself to go to Tehran 1979 in the middle of the Iran hostage crisis to try to negotiate with militants through the fence of the U.S. Embassy, and once called the Rev. Martin Luther King Jr.'s 1968 assassination "the chickens coming home to roost".
In 1984 Hansen was censured by the House for failing to include transactions on federal disclosure forms. He was defeated for reelection by less than 200 votes that year by Democrat Richard H. Stallings. Hansen tried unsuccessfully to challenge the election result. He was convicted of failing to file full disclosure forms and spent 15 months in prison. His imprisonment allegedly included torture through medical neglect and subjection to " diesel therapy," a form of punishment in which prisoners are painfully shackled and then transported for days or weeks without respite. The conviction was overturned in 1995 as a result of the U.S. Supreme Court decision Hubbard v. United States.