In some places it is illegal to walk around without carrying ID.
And the Supreme Court has determined that a citizen who is not committing a crime has a right to NOT be harassed by a cop for not carrying ID. Those laws will not hold up in court. This isn’t the Soviet Union, Not yet, anyway.