Legitimization

Legitimization ​is the process by which a bastard recieves the rights and social status of a trueborn.

Season 4
As a reward for relinquishing Moat Cailin from the ironborn, Roose Bolton presents his bastard son Ramsay Snow with a decree of legitimacy. This gives makes him an official Bolton and Roose's heir, with the right to inherit his lands and titles when he dies. Ramsay is grateful for this, and promises to uphold his father's name and traditions.

In the books
In the A Song of Ice and Fire novels, bastards can receive a bill of legitimacy, allowing them to take their father's surname and formally join his House, or to take a new surname and found a new House (some bastards take new names altogether, like "Blackfyre", while others add a prefix to their bastard name, such as "Longwaters"). For example, House Baratheon was founded by Orys Baratheon, the legitimized bastard half-brother of Aegon the Conqueror.. It is unclear whether a legitimized bastard would be placed in the succession according to birth order, or would be placed at the end, after the trueborn children.

However, while bastards stand outside the lines of succession and inheritance, there are still exceptions which have caused immense problems. King Aegon IV Targaryen legitmized three of his bastard sons and one of his bastard daughters on his deathbed. His eldest bastard son, Daemon Blackfyre, later claimed the Iron Throne and led a bloody civil war known as the First Blackfyre Rebellion. His sons and descendants launched four more attempts to take the Iron Throne before their final claimant, Maelys the Monstrous, was slain by Ser Barristan Selmy during the War of the Ninepenny Kings. This is sometimes used as an example of what happens if a bastard is treated too well and given too much power and legitimacy.

In the novels, Ramsay receives his decree of legitimacy from King Tommen Baratheon as a reward for the part his father played in the Red Wedding, as he was in need of an heir after the death of his trueborn son Domeric who apparently died of a stomach virus. Roose believes Ramsay to have poisoned Domeric out of jealousy of his status as their father's heir. He wins Ramsay's legitimacy despite this, as he believes that due to his age he will not live to see any children he might have with his new wife Walda live to adulthood, and suspects that Ramsay will kill them anyway.