The short answer: Saxe-Coburg and Gotha
Before it was called Windsor, the British royal house was known as the House of Saxe-Coburg and Gotha. The name came from Prince Albert, the husband of Queen Victoria, whose family ruled the German duchy of Saxe-Coburg and Gotha. In 1917, during the First World War, King George V announced that the family would use the name Windsor instead.
Why the name came from Prince Albert
Queen Victoria belonged to the House of Hanover, and she was the last Hanoverian monarch. Royal house names usually followed the male line, so when her son Edward VII became king in 1901, the house was regarded as that of his father. Edward’s reign, from 1901 to 1910, is generally counted as the period of the House of Saxe-Coburg and Gotha on the British throne. His son George V continued under the same name until 1917.
Some historians point out that the issue was never entirely tidy. Victoria’s own name for the family was not formally changed during her life, and there was no major ceremony in 1901. That is why you will see sources that handle the transition slightly differently.
Why the name changed in 1917
By 1917 Britain had been at war with Germany for nearly three years. A royal family with a German name and German relatives was open to criticism, and anti-German feeling was strong in the country. Public figures were also changing German-sounding names.
On 17 July 1917, George V issued a proclamation declaring that the royal house and family would be known as the House of Windsor. He also dropped his German titles and styles. Other relatives who lived in Britain gave up their German titles or changed their names around the same time. The wider background is covered in what was the name of the British royals before Windsor.
Why Windsor
Windsor Castle has been a royal residence for centuries, so the name sounded English, traditional and settled. It was also easy to say and did not belong to any rival branch of the family. The choice was meant to present the monarchy as thoroughly British, even though the family’s ancestry was not changed by it.
What about Mountbatten-Windsor?
There is a later layer to the story. When Queen Elizabeth II came to the throne in 1952, there was discussion over whether her husband’s family name, Mountbatten, should replace Windsor. The Queen decided that the house would remain Windsor. In 1960 it was declared that certain of her descendants who do not hold royal rank would use Mountbatten-Windsor as a surname. If you want to know how surnames work for royals today, see does the Royal Family in England have a surname.
For the larger story of the dynasty behind the old name, see the history of the Saxe-Coburg-Gotha royal family. The question of who was on the throne before the Windsors is also useful for placing the change in context.