The saying was already old when Shakespeare reached for it. The Oxford proverb tradition tracks the sentiment to Caxton’s Jason around 1477 (EETS edition p. 23), in wording no modern reader would recognise as the same proverb; the same entry also points to a comparable line in Euripides’ Suppliants about foresight comprising bravery, offered as a parallel rather than as part of the English lineage.
The reversal was under way well before the Victorian quotation books. In 1762 Charles Churchill put it in couplet form in The Ghost, Book I — “That, even in a hero’s heart, / Discretion is the better part” — already in the modern order, if not yet the modern phrase. Churchill published Books I–III of the poem in 1762 and Book IV in 1763.
Quote Investigator has not published an investigation of this line, and Wikiquote lists it only in its ordinary sourced section for the play, with no Misattributed or Disputed entry. Nothing in the record disputes that Shakespeare wrote the sentence — the dispute is entirely over the sentence people repeat.