From what I understand (although my English history is very poor), to be the monarch of England, one must convert to Anglicanism, as the monarch is also the head of the Anglican Church. I believed this had extended since the beginning of the Anglican Church with Henry VIII. But, I recently learned that James II and VII (just one person, two titles) was the last Roman Catholic monarch of England, Ireland, and Scotland (on the Wikipedia page for him), and he reigned in the late 1680s. Even just looking on the Wikipedia page for Anglicanism, it seems as though it was fairly well established by the 1680s, especially since Henry VIII reigned in the early 1500s. Am I missing something? Why was James II not forced to convert to Anglicanism? (And, if James II was allowed to keep his religion, would a modern-day English monarch be allowed to as well, or is there a legal reason why not today that there wasn't during the 17th century?)
The law requiring that the monarch be Protestant was passed in 1701 https://en.m.wikipedia.org/wiki/Act_of_Settlement_1701 (This was ultimately due to James' behaviour which led to his deposition) As such, the answer is, because there was no such requirement.
This question was extensively debated during the reign of his predecessor Charles II and defined the politics of the late 1670s and early 1680s. You can read extensively about this by searching on the phrase "Exclusion Crisis". Simply put, those who wanted to exclude James from the succession lost that particular battle at that time.
In a nutshell, Elizabeth died without children.
The Scottish King, James VI was invited to take the English crown and merge the Scottish and English crowns together.
James was a Protestant so this posed no problem. He became James I of England. As he was already James VI of Scotland, both numbers were used.
His son is Charles I who is the king executed during the English Civil War. Charles I is followed by his oldest son Charles II who returns from exile in France. He is well liked but dies childless.
The younger son James II and VII then becomes King. Problem is, James had become a Catholic while in exile in France. Suddenly, after 150 years of protestant rule a Catholic is back on the throne.
He lasts about 3 years until the Protestant establishment in both England and Scotland make an alliance with Holland and bring over William of Orange who has Anglo-Scottish royal blood.
A number of important events happen around this time.
Darien disaster - Scotland attempts to create a colony in the new world. It fails and the investors lose pretty much everything. Scotland practically bankrupts itself and is forced into parliamentary union with England to cover its debts.
It's made law that Catholics cannot be monarch.
Battle of the Boyne - last real chance of Catholics to turn the war around ends in their defeat. The last Catholic armies are allowed to flee to France which takes much of the Irish aristocracy out of the country - flight of the wild geese.
William of Orange is the reason the color orange is used in Ireland to represent the protestants including on the Irish flag.
The name James in Latin is Jacobus. Those who supported the exiled King became known as Jacobites. They launch several rebellions over the next 50 years ending with the defeat of Prince Charles Stuart's army at Culloden in 1746.
After that the Jacobites were finished and there was no chance of a Catholic monarch reigning in Britain.