Good question. Can't answer it since we don't know what jurisdiction is allegedly passing this law.
Is it legal? Yes. The states have the legal right to legislate for the public health, safety and welfare of their citizens. These are called "police powers".
I can see some issues here. First of all, children are prone to infections and if baby clothes have any diseases or worse yet, tainted materials in them, yes I can imagine a law barring resale of 2nd hand baby stuff.
A good example is stuff that babies stick in their mouths. Rattles, teething rings, etc. Short of autoclaving the stuff, I can see children passing diseases on. Its not likely but its possible.
Clothing can suddenly burst into flames with a tiny spark, or it could contain fillers like melamine, or something else. So yeah I see that one too.
In a way, if such a law were passed, I can see it being upheld if challenged.
Is it a smart law? No. Not really. It won't stop people from handing down clothes or being redistributed by charities. So people will cross state lines to get 2nd hand clothes.
It would also be a nightmare for ebay sellers. That's for sure.