The institution of the monarchy, said Boris Johnson, is beyond reproach. It was such an odd response to the scandal engulfing Prince Andrew – so stiff, so forelock-tugging, so initially lacking in sympathy towards the teenage girls abused by the prince’s late friend Jeffrey Epstein – that it stuck in the mind long after the televised leaders’ debate ended. Perhaps, I thought, he was simply afraid of offending the Queen any further after dragging her into a shabby, unlawful prorogation of parliament.

Yet now one wonders if Johnson had an inkling of what was coming, when he chose to defend not Prince Andrew personally but the institution from which the prince has essentially resigned. For it is the institution itself that is now in danger.

Had the infant Prince Charles been a girl, then Andrew would be our future king and this would be a constitutional crisis

Parents cannot sack their children. That is the immense power of ordinary families, but the fatal weakness of dynasties and, stupidly, the Duke of York has exposed it. Priests can be defrocked and politicians lose the whip, but a child born into a royal family cannot be unborn from it; merely hidden away in the hope that people forget about him. That now seems to be the fate of the Queen’s second son, who will undertake no public duties and take no public money from the government-issued sovereign grant for an unspecified period of time (although he will continue to be supported by his mother’s private estate). But his departure from the stage serves as an uncomfortable reminder that the people have no formal mechanism of redress against a royal figure who does something incompatible with public life, beyond hoping that they do the decent thing.

Had the infant Prince Charles been a girl, then under the rules of male primogeniture Andrew would be our future king and this would be a full-blown constitutional crisis. As it is, the odds on one have shortened, with speculation that he could end up testifying in the US courts. For republicans, this is thrilling. It’s a far bleaker moment for those of us with no great love for monarchy, but who fear worse would emerge from an elected presidency in this febrile climate. The Queen has been the one point of stability in a precarious world of late, but now she too is being sucked towards the vortex.

The rot doesn’t stop with the prince’s sexual conduct, whatever the ongoing legal process might ultimately conclude that to be. Why was he hanging around someone like Epstein in the first place? If it wasn’t for the girls, the answer can only be that he craved a billionaire lifestyle – one he felt befitted his royal status – on a £250,000 income, which may sound a fortune but is chicken feed to the super-rich. Epstein lent him private jets and exclusive holiday homes, introduced him to business contacts, wrote cheques to bail his ex-wife Sarah Ferguson. And he’s not alone. Remember the Kazakh oligarch who helpfully bought the Yorks’ marital home for £3m more than it was worth after the divorce, then left it empty for years? And just as they seem to have done with his Newsnight interview, the palace indulged all this. It has arguably lacked not only integrity, but a sense of self-preservation.

If the defence Prince Andrew outlined to Emily Maitlis is the one he gave the Queen and her advisers all along, arguably they should have withdrawn him from circulation earlier. But perhaps that’s what happens when one’s boss is also one’s mother. The genuinely historic miscalculation, however, was allowing the prince to breach the convention that royals stay under the parapet during a general election campaign. If December brings a hung parliament, in which the Queen must exercise even the most marginal of judgments about who can form a government, then those contrasting verdicts from the party leaders at the end of the televised debate – Johnson’s that the monarchy isn’t up for debate, Jeremy Corbyn’s that it “needs a bit of improvement” – might well return to haunt the process. Will one look retrospectively like a promise, the other more of a threat?

The greatest fear of senior royals has always been that when the Queen eventually dies, the monarchy might collapse. For the majority of Britons who are neither sworn republicans nor particularly ardent monarchists, the Queen is the one who really commands respect and affection, having earned the kind of trust that enables unelected power to be tolerated. But trust is not automatically inherited along with the crown. It is significant that Andrew’s resignation came after the Queen consulted her heir.

Prince Charles is said to favour a slimmed-down future monarchy, focused on himself, his wife and his sons, although it’s never been clear what would happen to royals deemed redundant. The Duke of York can hardly spend the rest of his life playing golf and, to put it mildly, it’s difficult to see him succeeding in the working world strictly on his own merits. Some kind of restructuring looks almost inevitable, but it should be accompanied by a broader review of the family’s role in public life and of the monarch’s constitutional powers, which recent political turbulence has exposed to the limelight.

Twice in my lifetime, the royals have emerged unscathed from potentially serious trouble; first, when Prince Charles’s affair with Camilla Parker Bowles became public, prompting concerns the nation would reject him as king, and, second, after Princess Diana’s death, when senior figures seemed out of touch with public grief. But this time it’s worse, because this goes beyond a prince’s individual flaws to reveal something about the institution that produced him. If the monarchy cannot put its house in order, it should not be surprised if the nation ultimately seeks to do it for them.

• Gaby Hinsliff is a Guardian columnist