It's not that easy. Karoline of the Palatinate, in case she was recognised in the UK as legitimate, would have been higher up the line of sucession than her aunt Electress Sophie, because her father was Sophie's elder brother. As she had a son at the time of the decision on the Hanoveran succession and was married to a then British duke, I guess she was not deemed legitimate enough to inherit her grandmother Elizabeth Stuart's right to the British thrones. While her aunt Sophia was.
one great reason why Karoline was not chosen and was passed over for Sophia is because, Karoline was long dead by that time.. also, their marriage was done in Europe where the practice of morganatic marriage is strictly followed.. this would make their children legitimate, but does not possess any dynastic right to their father's claim.. i believe that the reason why Electress Sophia of Hanover was chosen because she's the senior most protestant relative of King James I.. but your are right, that Electress Sophia was not the senior most cognatic descendant of King James I to be protestant.. i believe it was Frederica Mildmay, Countess of Mértola, granddaughter of Charles I Louis of the Palatinate via her daughter Karoline of the Palatinate..
Electress Sophia being chosen as the heir is the best thing they can thing off.. despite of legitimate birth, Federica would be considered to low in rank to succeed Queen Anne.. plus, powerful countries such as the France, Spain, Modena and the Papal States still contest that James Francis Edward Stuart is the legitimate king.. declaring a mere countess of morganatic birth and who possessed no territorial power despite being of legitimate birth would weaken the claim for a new monarch.. Opposing countries would have a field day if parliament would chose Feredica as queen.. also, 56 people who had more legitimate hereditary claims were bypassed in favor of Sophia..
Because of the Act of Settlement, ensuring the Protestant Succession, on the death of Queen Anne on 12 Aug 1714, she was succeeded by the Elector of Hanover. This succession bypassed more than fifty people then living who had better claims to the throne according to primogeniture. The following chart will show those people, and only those who are relevant to this issue are included. Those living at Queen Anne's death are in capital letters:
King James I & VI of England and Scotland (156601625) and his wife Anne of Denmark (1574-1619) had the following relevant issue:
1. King Charles I of England and Scotland (1600-1649); m.Henriette Marie of France (1609-1669)
1.1. King Charles II of England & Scotland (1630-1685); m. Caterina of Braganza (1638-1705)
1.2. King James II & VII of England & Scotland, deposed 1688/9 by William & Mary; (1633-1701); m.1st Anne Hyde (1637-1671); m.2nd Maria Beatrice d'Este of Modena (1658-1718)
1.2.1. JAMES EDWARD Stuart, "The Old Pretender" (1688-1766); m.1719 Clementina Sobieska (1702-1735)
1.2.2. Queen Mary II of England and Scotland (1662-1695); reigned 1689-95; m.King William III (below)
1.2.3.Queen Anne of Great Britain (1665-1714); m.Pr George of Denmark
(1653-1708)
1.3. Mary (1631-1660); m.Pr Willem II of Orange-Nassau, Stattholder of the Netherlands (1625-1650)
1.3.1. King William III of England and Scotland, etc (1650-1702); reigned
1689-1702; m.Queen Mary II (above)
1.4. Henrietta (1644-1670); m.1661 Philippe, Duc d'Orleans (1640-1701)
1.4.1. ANNE d'ORLEANS (1669-1728); m.1684 King Vittorio Amedeo II of Sardinia (1666-1732)
1.4.1.1. VITTORIO AMEDEO OF SAVOY, Prince of Piedmont (1699-1715)
1.4.1.2. King CARLO EMANUELE III OF SARDINIA (1701-1773)
1.4.1.3. Marie Adelaide of Savoy (1685-1712); m.Louis, Dauphin of France
(1682-1712)
1.4.2.1. LOUIS, DAUPHIN OF FRANCE [later, King Louis XV] (1710-1774)
1.4.3. Maria Luisa of Savoy (1688-14 Feb 1714); m.King Felipe V of Spain
(1683-1746)
1.4.3.1. LUIS, INFANTE OF SPAIN [later, King Luis I] (1707-1724)
1.4.3.2. INFANTE FELIPE OF SPAIN (1712-1719)
1.4.3.3. INFANTE FERNANDO OF SPAIN [later, King Fernando VI] (1713-1759)
2. Elizabeth (1596-1662); m.Friedrich V, Elector Palatine, King of Bohemia
1619-21 (1596-1632)
2.1. Karl I Ludwig, Elector Palatine (1617-1680); m.1st 1650 (div 1657)
Landgravine Charlotte of Hesse-Cassel (1627-1686); m.2nd 1658 Baroness Marie Luise von Degenfeld
(1634-1677)
2.1.1. LISABETH CHARLOTTE (1652-1721); m.Philippe, Duc d'Orleans (1640-1701)
2.1.1.1. PHILIPPE II, DUC d'ORLEANS (1674-1723); m.Francoise Marie of France (1677-1749)
2.1.1.1.1. LOUIS [later, Duc] d'ORLEANS (1703-1752)
2.1.1.1.2. LOUISE d'ORLEANS (1695-1719); m.Charles, Duc de Berry (1686-1714)
2.1.1.1.3. MARIE ADELAIDE d'ORLEANS (1698-1743)
2.1.1.1.4. CHARLOTTE d'ORLEANS (1700-1761); m.1720 Francesco III d'Este, Duke of Modena (1698-1780; below)
2.1.1.1.5. ELIZABETH d'ORLEANS (1709-1742); m.1723 King Luis I of Spain
2.1.1.2. ELIZABETH d'ORLEANS (1676-1744); m.1698 Duke Leopold of Lorraine (1679-1729)
2.1.1.2.1. LEOPOLD OF LORRAINE (1707-1723)
2.1.1.2.2. FRANCIS STEPHEN OF LORRAINE (1708-1765); as of 1745 he was the EMPEROR FRANZ; m.1736 Archduchess Maria Theresia of Austria (1717-1780)
2.1.1.2.3. CHARLES OF LORRAINE (1712-1780)
2.1.1.2.4. ELIZABETH THERESE OF LORRAINE (1711-1741); m.1737 King Carlo Emanuele III of Sardinia (1701-1773)
2.1.1.2.5. ANNE CHARLOTTE OF LORRAINE (17 May 1714-1773)
2.1.2. Karoline, Raugraefin (1659-1696); m.1683 Meinhard von Schomberg, Duke of Leinster (1641-1719)
2.1.2.1. Lady Mary Schomberg ( - ); m.CtDegenfeld; she was probably alive at Anne's death, and may have had living kids, but I have no further details
2.1.2.2. LADY FREDERICA SCHOMBERG (d.1751); m.1st Robert D'Arcy, Earl of Holdernesse (d.1722); m.2d 1724 Benjamin Mildmay, Earl Fitzwalter (d.1756)
2.2. Eduard, Ct Palatine von Simmern (1625-1663); m.1645 Anna Gonzaga
(1616-1684)
2.2.1. Luise Marie, Css Palatine von Simmern (1647-1679); m.1671 Fst Karl
Theodor zu Salm (1645-1710)
2.2.1.1. PRINCE LUDWIG OTTO ZU SALM (1674-1738); m.1700 Pss Albertine Johannette of
Nassau-Hadamar (1679-1716)
2.2.1.1.1. PRINCESS DOROTHEA FRANZISKA AGNES ZU SALM (1702-1751); m.1719 Prince Nikolaus Leopold zu Salm-Salm (d.1770)
2.2.1.1.2.Pss ELISABETH ALEXANDRINE CHARLOTTE ZU SALM (1704-1739); m.1721 Pr Claude Lamoral de Ligne (d.1766)
2.2.1.1.3. Pss CHRISTINE ANNA LUISE OSWALDINE ZU SALM (1707-1777); m.1st 1726 Pr Joseph of Hesse-Rheinfels-Rotenburg (d.1744); m.2d 1753 Fst Nikolaus Leopold zu Salm-Salm (d.1770)
2.2.1.2. Pss ELEONORE CHRISTINA ZU SALM (1678-1737); M.1713 Conrad, Duc d'Ursel (d.1738); they may have had a kid before Anne's death, but I don't know for sure
2.2.2. ANNE, Css PALATINE VON SIMMERN (1648-1723); m.1663 Henri Julius, Pr de Conde (1643-1709)
2.2.2.1. LOUIS III, DUC DE BOURBON, PRINCE DE CONDE (1668-1710); m.1685 Louise Francoise de Bourbon (1673-1743)
2.2.2.1.1. LOUIS IV HENRI, DUC DE BOURBON, PRINCE DE CONDE (1692-1740); m.1713 Marie Anne de Conty (below)
2.2.2.1.2. CHARLES DE CONDE, PRINCE DE CHAROLAIS (1700-1760)
2.2.2.1.3. LOUIS DE CONDE, COMTE DE CLERMONT (1709-1771)
2.2.2.1.4. MARIE ANNE DE CONDE (1690-1760)
2.2.2.1.5. LOUISE ELIZABETH DE CONDE (1693-1775); m.1713 Louis Armand II, Pr de Conty (d.1727; below)
2.2.2.1.6. LOUISE ANNE DE CONDE (1695-1758)
2.2.2.1.7. MARIE ANNE DE CONDE (1697-1741); m.ca 1719 Louis de Melun, Duc de Joyeuse (d.1724)
2.2.2.1.8. HENRIETTE LOUISE DE CONDE (1703-1772)
2.2.2.1.9. ELIZABETH ALEXANDRINE DE CONDE (1705-1765)
2.2.2.2. MARIE THERESE DE CONDE (1666-1732); m.1688 Francois Louis, Pr de Conty (d.1709)
2.2.2.2.1. LOUIS ARMAND II, PR DE CONTY (1695-1727); m.1713 Louise Elizabeth de Conde (above)
2.2.2.2.2.MARIE ANNE DE CONTY (1689-1720); m.1713 Louis IV Henri, Pr de Conde (above)
2.2.2.2.3. LOUISE ADELAIDE DE CONTY (1696-1750)
2.2.2.3. ANNE LOUISE DE CONDE (1676-1753); m.1692 Louis Auguste de Bourbon, Duc de Maine (d.1736)
2.2.2.3.1. LOUIS II AUGUSTE, DUC d'AUMALE (1700-1755)
2.2.2.3.2. LOUIS CHARLES, PRINCE DE DOMBES (1701-1775)
2.2.2.3.3. LOUISE FRANCOISE, Mlle DU MAINE (1707-1743)
2.2.2.4. MARIE ANNE DE CONDE (1678-1718); m.1710 Louis Joseph de Bourbon, Duc de Vendome (d.1712)
2.2.3. BENEDIKTE HENRIETTE, Css PALATINE VON SIMEMRN (1652-1730); m.1668 Duke Johann Friedrich of Brunswick-Lueneburg (1625-1679)
2.2.3.1. Charlotte (1671-1710); m.1696 Rinaldo III d'Este, Duke of Modena
(1655-1737)
2.2.3.1.1. FRANCESCO III, DUKE OF MODENA (1698-1780); m.1720 Charlotte d'Orleans (above)
2.2.3.1.2. GIOVANNI FEDERIGO d'ESTE (1700-1727)
2.2.3.1.3. BENEDETTA d'ESTE (1697-1777)
2.2.3.1.4. AMALIA d'ESTE (1699-1778)
2.2.3.1.5. HENRIETTA d'ESTE (1702-1777); m.1st 1728 Antonio Farnese (d.1731); m.2d 1740 Ldgve Leopold of Hesse-Darmstadt (d.1764)
2.2.3.2. HENRIETTE OF BRUNSWICK-LUENEBURG (1672-1737)
2.2.3.3. WILHELMINE AMALIE OF BRUINSWICK-LUENEBURG (1673-1742); m.1699 Emperor Josef I (d.1711)
2.2.3.3.1.Archduchess MARIA JOSEFA OF AUSTRIA (1699-1757); m.1719 Elector Friedrich August II of Saxony, King of Poland (1696-1763)
2.2.3.3.2.Archduchess MARIA AMALIA OF AUSTRIA (1701-1756); m.1722 Elector Karl Albert of Bavaria, who became Emperor Karl VII (1697-1745)
2.3.Sophie of the Palatinate (1630-18 Jun 1714); m.1658 Elector Ernst August of Hanover (1629-1698)
2.3.1.ELECTOR GEORGE OF HANOVER -- became KING GEORGE I OF THE UNITED KINGDOM
we are talking about playing a game of thrones.. not all legitimate descendants are able to take their hereditary rights.. Wilhelm Karl, Duke of Urach was the legitimate heir to the throne of Monaco, but was passed over for his illegitimate niece Charlotte.. Alfonso de la Cerda, ancestor of the Dukes of Medinaceli is the legitimate heir to the throne of Castile, but was usurped by his uncle Sancho IV.. saying that her being of illegitimate line is the reason why she was debarred from the line of succession would be too absurd seeing there are other criteria to consider and Sophia fits the job perfectly..