One thing I keep hearing as an attorney is about how x is unconstitutional (when it really is constitutional), or how I hear y is a great program and that there's no reason for it to be unconstitutional, and so on. So, let's lay down a few laws about I think is constitutional and what's not.
First the framework - the Constitution of the United States of America is an amazing document that lays out what the Federal Government and the State Goverments can and cannot do, and lays out our various freedoms. As this document is based upon the work of John Locke, the Constitution is generally concerned with life, liberty and property, plus a few protections actually spelled out (freedom of religion, speech, due process, equal treatment, etc.)
Now, let's consider this for a brief moment - virtually every part of your life, your property and your liberty are regulated in some way, shape or fashion. So, if the Constitution is supposed to protect those things, what gives? Well, because government couldn't effectively function without regulating your life in some way, courts will allow the government to interfere with your rights if it has a good reason.
Take jaywalking, for instance. State governments can actually prohibit you from walking across the street where you want, and when you want. Why? Because people are dumbasses and will get themselves killed by oncoming traffic. Also, jaywalking laws don't take away your liberty as much as ask you for a few seconds of your time. Because its a low level right (seriously, you don't need to cross the street that fucking badly), Courts will allow this one if the government has a reason for it.
As you go up the ladder of rights, reasons need to get better and better. Say you want to forcibly sterilize women who have mental disabilities because you don't want them to have kids with mental disabilities - woah, woah, hold up there mister. That kind of regulation crosses too many lines, because you're fucking with someone's ability to have kids - a major part of the right to life and liberty. There have better be a damned good explanation for that.
There are also some areas where the Courts won't buy the government's argument. This is especially true if the regulation has to do with anything race-based. Thanks to 100 years of segregation and Jim Crow laws, anything that remotely touches on race comes with a "you better have all your ducks in a row, Government" warning label. With gender discrimination, the level isn't quite as high, but its close.
There is also another intervening factor - the Constitution actually gives the government the right to do stuff. As you might expect, if the government has the right to do something, then fuck all rights. Conscription, for instance, affects the right to life, liberty, property and a whole host of other rights, but the Courts let it through because Congress has the right to pass laws to create armies and navies. Civil rights laws are explicitly allowed because Congress has the right to affect interstate commerce (which is basically everything) and have the right under the 13th, 14th, and 15th amendments to pass laws to guarantee equality.
But when faced with what's constitutional or not, the issue is 1) how important is the right affected by the law; 2) how good is the government's reason for the intrusion; and 3) does the Government have an explicit right to intrude on your rights? So, when the Courts say something is unconstitutional, its generally because they've done that analysis. Now, they're not always right, but they all follow this general framework.