The story
Compare swear to God. Originally used as a sentence adverb or interjection, modifying entire clauses or utterances; honest itself is used this way, as in “Honest, I had no idea!” (meaning “I'm telling the truth, I had no idea!”).
Etymology from Wiktionary, CC BY-SA 4.0.