"No quarter" is, simply, military terrorism. It is aimed at the immediate enemy, both soldiers and civilians, and future or potential enemies. It is sometimes aimed at one's own soldiers.
The best known military use is in sieges. The choice given to the defenders was simple: surrender now or die. If this choice was given at the beginning of a siege, it was an attempt to avoid the siege altogether. Sometimes, the defenders were given generous terms, such as being allowed to leave with all their weapons and some supplies. Sieges were expensive and dangerous - soldiers needed to be paid and fed, and the besieging army was vulnerable to outbreaks of disease. If the defenders could be terrorised into prompt surrender, that could be avoided.
This was the usual pirate usage, too, to encourage the targeted ship to surrender instead of fleeing or fighting. It is safer to loot a surrendered enemy than to have to fight them first. Even if victory is likely, there will be casualties, and there is a chance of catastrophe (e.g., a lucky shot bringing down rigging, a powder explosion on the gun deck, and in the worst case, a magazine explosion destroying the ship).
The defenders of a fortress might not be treated well by their own side if they surrendered and abandoned the fortress as soon as the enemy appeared. "Treasonous!", their king might say. The defenders were, quite often, given a chance to honourably defend their fortress. This might be a time limit - if a relief force doesn't arrive within 20 days, they surrender (or the siege proceeds, with no quarter given). Often, once the walls were breached, the defenders would be given the choice: surrender, or no quarter will be given.
Sometimes, the defenders were given less choice. The attacker simply declared that no quarter would be given. In these cases, the defenders would typically fight to the death, since they had nothing to lose. However, in these cases, they were not the main target of the no-quarter policy. The terror was aimed at other potential enemies. For example, if a city revolted, it might be treated in this way. Since they has committed treason, they could expect to be executed anyway, even without a declaration of no quarter. The message was to other cities: "if you revolt, we will kill you".
"No quarter" was used outside sieges, revolts, and piracy, too. One notorious relatively recent example is the Confederate policy of no quarter for black Union soldiers and their officers during the US Civil War. In principle, the official policy was that captured black troops were be enslaved or re-enslaved, but in practice they were usually shot or otherwise murdered on capture. Their officers were executed for the supposed crime of incited slave insurrection. The targets of this terror policy were enemy troops (to discourage black soldiers from enlisted, to encourage them to desert, to flee from the battlefield, and to discourage white officers from commanding them) and Southern blacks. For more on this, see
The English Parliament passed laws in 1644 prescribing no quarter for Irish and "Papists born in Ireland" if they were captured fighting Parliament in England, Wales, or at sea:
One case of both sides in a war using "no quarter" for terror was Charles the Bold, Duke of Burgundy, fighting the Swiss. In 1476, he sought to recapture a fortress, the castle of Grandson, which had been taken by the Swiss the year before. The fortress was besieged, and with no relief force in sight, the Swiss garrison surrendered. According to the Swiss chroniclers, the garrison was offered free passage. Instead, Charles had them all executed. Charles's historian claimed that the garrison had thrown themselves on his mercy. Either way, the execution was intended to terrorise the Swiss. Brutality and terror were standard tactics for Charles; he was also called Charles the Terrible. In 1468, he had destroyed Liege, which was not rebuilt until after his death. When Charles took Nesle in 1472, the defenders were massacred, except for some archers who were allowed to live after having their right hands cut off. Charles was a terrorist (in the broad sense of the word), and applied his usual methods to the Swiss. This was the second time that Charles had done such a thing to the Swiss. The previous year, when he took Briey from the Swiss, the Swiss handed over the fortress and a large sum of money, in return for free passage. Charles hung them all instead. Earlier in that year, when the Swiss took Murten, they had made the usual offer: surrender, or we will give no quarter. Murten surrendered, and the garrison was allowed to leave. The Swiss respected the customary laws of war concerning sieges, surrender, and quarter. Charles did not.
A few days later, the Swiss relief force arrived, and won a quick and relatively bloodless battle. Then they discovered that the garrison had been executed, many of them still swinging from the trees where they had been hung. The Executive Council of the Swiss Confederation revised their rules of war: from now on, Swiss troops were "so far as possible to kill our enemies", and no prisoners were to be taken during a battle.
Three and half months later, the Swiss (and their allies from Lorraine) met the Burgundians at Murten (AKA Morat, in French). Charles's immediate target was Murten; his main objective was Bern. Charles made the customary offer to the garrison of the fortress: surrender now, or no quarter. The garrison was determined to resist - Charles's reputation left them with little hope for survival if the surrendered anyway. By 18th June, Charles's artillery had breached the walls, and an assault was made. The assault failed. On that same day, the Swiss relief force was ready, and marched toward Murten. They arrived on the 22nd, and attacked. Charles had prepared field fortifications to protect his force, with plentiful artillery. Despite the artillery, the Swiss pressed their attack, and took no prisoners. The Burgundian force broke, with men trying to flee. Murten was on the shore of Lake Murten, and the lake impeded the retreat of many. Many drowned, and others moved as far into the lake as they could while keeping their feet. The Swiss killed those they could reach from the sure, and used boats to kill the others. Some Burgundian soldiers tried to surrender; they were killed. Perhaps half of the Burgundian force escaped, and Charles was among them. The two armies had been about equal in strength, and the Burgundians had been protected by field fortifications and artillery; this was a devastating defeat for them.
Charles met the Swiss again at the start of the next year. This time, his army was greatly outnumbered, perhaps by about 4 times. This time, the destruction of his army was almost total, and Charles met his end at the business end of a Swiss halberd.
Approaching the battle with a stated policy of no quarter had multiple purposes for the Swiss. It sent a message to the Burgundians: if you don't run from the battlefield early enough, we will kill you. It sent a message to their own troops: we demand that you show no quarter to the enemy - do not stop to be merciful, or will treat you as a coward and traitor. The message the Swiss sent to potential enemies was simple: respect the laws of war when our men surrender, or we will kill you like we killed the Burgundians.
To return to pirates, the classic black flag, the Jolly Roger, was used, at least some of the time, as their signal for "if you resist, we will give no quarter". Some pirates used a red flag, with the same meaning. With either flag, the message was the same: "We are pirates, so surrender now, and don't try to flee or fight."
Wow, this is great! Appreciate the in depth answer.