Yes, there certainly are circumstances that require programmers to hold security clearances. The most common is when working for directly for the federal government at any of a number of agencies including the Department of Defense, Department of State, FBI, NSA, and a number of others. In the private sector, you'll most commonly see clearance requirements for jobs working with defense contractors, though it could feasibly be a component of a job for any government contractor.
In order to obtain a security clearance, there must be a necessity. It's not like a certification that you can get just to make yourself more employable...It must be obtained in concert with a project or position that requires you to be handle classified information. Classified information could mean anything from the contents of sensitive communications, to plans, to specifications of weapon systems, even down to the implementation details of software that serves a sensitive purpose. Clearances also don't last forever. Not only is periodic re-certification required, but if you leave the position that requires you to hold a clearance, it will eventually expire, assuming you don't take another position that also requires clearance, of course.
Clearance is not something you can pursue as an individual. It must be justified by the agency or company that you work for, based on the fact that they already have programs or contracts in place that require them (and therefore you) to deal with classified information as I described above.
For additional information on security clearances in the U.S. (the country for which this answer applies) the State Department website has details.