When you do something unwittingly, you don't do it on purpose. It's completely accidental or unintentional, like when you unwittingly offended the Queen by not curtseying properly.
If you know exactly what you're doing, you're not doing it unwittingly; you're doing it intentionally. This adverb comes from unwitting and its Old English root unwitende, "ignorant." Wit means "knowledge," so if you do something unwittingly, you act without knowledge. If you post too much personal information online, you might unwittingly set yourself up to have your identity stolen.