Before it meant opposition, protest meant public witness. The word comes from Latin prōtestārī — prō- ('forth') and testārī ('to bear witness'). To protest was to step forward and declare something true, loudly and on the record.
The phrase 'I protest my innocence' preserves this original meaning. The speaker is not objecting to anything — they are testifying, bearing public witness to their own blamelessness. This declaratory sense dominated for centuries.
The shift to opposition happened through frequency. The most common reason to make a public declaration was disagreement. Over time, the occasion ate the definition: protest became synonymous with objection.
The most consequential use of the word came in 1529. At the Diet of Speyer, a group of German princes issued a formal protestatio — a public declaration — against the Catholic majority. They were called Protestantes: 'those who testify forth'. The entire Protestant tradition takes its name from this single act of public witness.
The Latin root testis ('witness') runs deep in English. Testament is a witnessed document. Testimony is the act of witnessing. Contest is witnesses called together. Detest originally meant 'to curse while calling the gods as witnesses'. In each case, the core act is the same: standing forward and declaring something to be true.