In principle some things are left to the states instead of being enacted at the federal level because of cultural differences across various parts of the US. A law that is appropriate for the urban areas that make up most of Massachusetts might not be useful or reasonable in the plains of Wyoming.
In reality, things often end up getting punted to the states because it’s easier to pass legislation through the federal Senate if Senators can be assured that their state doesn’t have to enact certain more controversial portions of the bill if they don’t want to.
In other cases, law diverges from state to state because of enforcement practices. The Supreme Court has maintained that the federal government cannot prosecute state governments for refusing to enforce federal law. This is how we get things like state-level marijuana legalization. It is still illegal at the federal level, but an Obama-era memo indicates that the feds won’t go after people for breaking marijuana law, and certain states have decided that state-level law enforcement also won’t go after people. That’s also how you get things like sanctuary cities, etc.
Another example of this is when the Affordable Care Act was being debated in 2009, originally it was going to include its expansion of Medicaid at the federal level. But the way they were going to make states comply was to threaten them with the removal of all Medicaid funding if they didn’t, and the Supreme Court ruled that this punishment was so severe that it was akin to prosecuting a state for not upholding federal law, which is, again, unconstitutional. And that’s how we ended up with Medicaid expansion as an opt-in program, which I personally think kind of sucks, because there’s no reason why a poor person in Wyoming doesn’t deserve access to healthcare as much as a poor person in Massachusetts.
This whole principle of not being able to punish states for breaking federal law had led to all sorts of fuckery in recent months. A little while ago, Idaho decided to just blatantly ignore the Affordable Care Act and start telling insurers they could resume discriminating against people with pre-existing conditions again. Luckily CMS decided to bring down the hammer. I didn’t think they would; I was sweating about it for awhile.