This is a very complicated question.
In general, the Constitution spells out which powers are given to the states and which are given to the national government. States then get to decide what powers their local governments have.
The national government gets most of its power over the states from its power to regulate interstate commerce. This is, for example, why the national government can ban discrimination -- it can ban it in any establishment that is part of interstate commerce (and nearly everything is).
The states have pretty much exclusive power over things like voting rules, taxes, and criminal laws. So, for example, Congress could not pass a law banning the death penalty in the states. It could end the death penalty for federal crimes, but not for state crimes.
However, the national government can exert power over the states by threatening to withhold money if the states don't do what it wants. This is how the No Child Left Behind law works. States generally get to do what they want in education, but the national government says "if you don't do it our way, we won't give you any of this money that we give out to the states."