The preparation of a protocol is an important step in the research process in order to adequately consider the research aim, planning before you begin, and collaborators can give feedback and agree to their responsibilities. The protocol provides the basis for funding and ethics considerations.
A protocol also guards against scope creep. You need to state deviations from this protocol in a manuscript, for example, when the the analysis plan needed to be changed due to unexpected data properties.
Note: Some of the aspects below will not be relevant for some study types.