Good question! It's quite a famous quote this one, and like so many other "big quotes" in Shakespeare, I'm always surprised at how few people who quote it actually know what it means!

Here's the bit of the text with the quote in:

PORTIAWhat mercy can you render him, Antonio?

GRATIANO A halter gratis; nothing else, for God's sake.

ANTONIO So please my lord the duke and all the court To quit the fine for one half of his goods, I am content; so he will let me have The other half in use, to render it, Upon his death, unto the gentleman That lately stole his daughter: Two things provided more...

So what's happened here is that Shylock's legal claim for his 'bond' has just been defeated by Portia (disguised as a male lawyer) in open court. Shylock isn't going to get his pound of flesh from Antonio, because his bond doesn't include any blood - and he must necessarily shed blood in cutting off flesh! So Shylock's game is over.

But then comes the matter of punishment. What is Antonio going to choose as Shylock's punishment for so breaking the Venetian law in such a vile way - and that indeed, is Portia's question. Gratiano, shouting from the public audience seats, makes a suggestion of what "mercy" (a key word in this scene of the play - and indeed, in the play as a whole) Antonio can afford to Shylock...

A halter, and one that will be 'gratis' - that is, free of charge. And what is a halter? A noose which goes around someone's neck. And why might Gratiano want Shylock to be given a noose? To hang himself.

From a character called Gratiano, a name which suggests grazia, the Italian for “grace”, this is hardly grateful, or merciful. The behaviour contradicts the suggestion of the name - a very common theme in this particular play.