It offers you a way out until the DA decides that it is you who will be given immunity. In the federal system and numerous states, once the U.S. Attorney (the federal equivalent of the local D.A.) decides that it is you (for whatever reason) who will be granted immunity, the court has very little role in issuing the immunity order. Most states require an order to be issued by a court before being compelled to testify.
Usually, the court must issue the order if it is shown that the witness would not testify without immunity and the prosecution concludes that granting immunity is in the public interest; if that sounds broad, that is because it is. The court cannot refuse to grant it on the ground that the prosecution erred in reaching that conclusion.
Once granted, the witness must testify or face contempt charges, unless there is a valid reason for doing so (e.g., attorney-client privilege). You can't refuse to testify out of fear of physical harm.
Until you are faced with that decision, you are right, shut the fuck up and only consult with your lawyer. I guess my point is that somebody usually turns when that decision is pushed in their face.
Finally, if it is the feds who want someone, they are usually fucked, because they have virtually infinite resources.
I hope this clarifies some things.
The above is not legal advice and was written solely for entertainment purposes.