They don't have to go public with their identities though. The government knows, but their enemies and friends do not. Spiderman chose to reveal his identity, which was absurd, and he paid the price you describe. The act does not require that their identities be made public.
Well spaz the alternative is wide spread vigilantism with no accountability for heroes when they mess up. Also heroes aid in the release of criminals because they don't testify or provide evidence which leads to cases being dismissed.
As for the guy above me, police officer identities are already public you stooge.