Very high-level workflow (from user perspective) how to sign documents can be found on MS support site. Besides, that link also explains why it can be necessary.
Also, please, refer to the article on Wiki in order to get general understanding of digital signatures.
It would be nice to have a API for signing ODF documents as specified in ODF spec. part 3 section 3.5.