While James's goal of religious toleration was good, his execution was flawed. Â After his reign began, James broke the law -specifically the Test Act- and began appointing Catholics as officers in the army and navy. Â James entrusted the army to the command of the Earl of Feversham, a naturalized Frenchman and fellow Catholic convert, who was a less than competent commander. Â
The officers of the army and navy, particularly John Churchill, realized that James was going to continue to favor Catholics, decreasing the likelihood of their promotion. Â Churchill was particularly bitter because he did more than anyone to defeat Monmouth in the rebellion of 1685, yet Feversham got all the credit. Â The officers were also eager to go to war against Louis XIV.
Thanks to the revocation of the Edict of Nantes in 1685, the English were paranoid about what James might do to Protestants in his kingdoms. Â Although James claimed his goal was universal religious toleration, he was privately urging his friends and chief servants to become Catholic, including Samuel Pepys; this became well known, as well as his actions with the army and navy.
I don't think that James II would have lost his throne if he hadn't violated the Test Act, which caused key officers in the army to plot against him. Â If he had allowed the army and navy to remain Anglican, and focused on religious toleration in private life, he might have had a chance. Â
The second reason James lost his throne was his failure to join the coalition against Louis XIV. Â He was repeatedly offered the chance to do so, and did not even have to commit troops, just provide subsidies. Â Unfortunately, long before his son was born, everyone knew that James planned to sit the upcoming war against Louis XIV out, and the warming-pan slander was concocted.