Citation needed.
It is legal (at least based on the guidelines provided by the US Department of Labor: http://www.onetcenter.org/dl_files/empTestAsse.pdf) to give people all kinds of tests as long as (a) they do not select against certain protected traditionally disadvantaged classes more than it does for the average applicant or (b) if it does, there is a demonstrable link between the test and ability to perform job functions (so, for instance, a test of strength in a job that involves lots of lifting may select against women, but if strength is highly correlated with job performance, that is OK).
IQ tests are actually a fairly poor test for many jobs, and they can test many things besides just intelligence (for instance, knowledge of the English language or cultural trivia). For a blue-collar job, an IQ test may disadvantage people from a different cultural background or who don't speak English as a native language, without actually being particularly relevant to job performance. One of the cases that has come up many times is in fire departments, in which written tests are given and used to screen out applicants who score below a certain level, when much of the knowledge tested is not actually all that important to the job.
These days, for a programming job, you would give a more specific test of programming ability. At the time, given that there probably weren't a lot of people with training or experience programming who could be hired, an IQ test was probably a reasonably good generic stand in for the aptitude to learn and think critically.