It's Almost Hopeless
Assuming this is a standard Goblin with no special tricks, there's not a whole lot you can do. You'd want to use Escape Artist to try and break the grapple (as it's going to be higher than the -3 on a grapple check), but then you have to get away and that will be pretty difficult with sword guy standing right there.
Fighting out will be almost impossible, since you have to attack the one grappling you first, while hoping the one with the sword doesn't hit you (because with 5 HP, you can't take many hits). Maybe if you were incredibly lucky.
Talking Is Your Best Bet
If the PCs are holding the Goblin at sword point, you've got the opportunity to try and talk your way out of it. Maybe the PCs want information. If the Goblin knows something, he could try and trade it for his freedom (and hope the PCs are lawful enough to honor an agreement).
If the Goblin doesn't know anything... he can lie. Goblins have a lousy bluff, but if your PCs have a lousy sense motive, maybe you can get away with it. At low level a good die roll will get you a long way even with a lousy modifier.
Mechanically - How to Get The Goblin Into That Position
You'd start off with a grapple, as you already did. While grappling, the best thing for the attacker to do is to try and pin the Goblin. Pin is done with an opposed grapple, while already grappling. If the attempt is successful, the link I just gave explains what happens. In a nutshell: the one being pinned can't really do much of anything except try and escape. You can even be prevented from speaking. (Note: you are not helpless for the purpose of a coup-de-grace.) The person doing the pinning is in control at this point.
Of particular use with a pin is that if the Goblin escapes the pin, he's still grappled. That gives the PC a chance to re-establish the pin, making it very good for holding things in place.
"Holding a sword to his throat" is a narrative statement, there is no specific rule that covers it. If a Goblin is pinned, though, it's pretty easy to visualize what's going on. What the rules do offer you is the ability to react to an escape attempt, using a Ready Action. That lets the PC holding the sword say "I'm holding the sword to his thraot, and if he breaks the pin I attack him."
The way that works is if the described event happens, the PC immediately gets to take a standard action, doing what he described. So the scenario goes like this:
- PC A grapples goblin.
- PC A pins goblin.
- PC B moves next to A, says that he's putting his sword to the goblin's throat, and declares a ready action to attack if the goblin breaks the pin.
If the goblin does break the pin, PC B immediately attacks.
You can do all this without pinning and with just using grapple, but I find the narrative of what you're describing as the situation fits really well with a pinned goblin, as it's pretty hard to put your sword to the throat of a creature that's actively grappling with your friend.