From Latin 'firmus' (firm) — the legal distinction from 'swearing' was created to accommodate Quakers.
To state something as true with confidence; to offer emotional support or validation; to uphold a legal decision.
From Old French 'afermer' (to affirm, confirm, establish), from Latin 'affirmāre' (to make firm, to strengthen, to confirm, to assert positively), from 'ad-' (to, toward) + 'firmāre' (to make firm, to strengthen), from 'firmus' (firm, strong, stable, enduring). The Latin 'firmus' derives from PIE *dʰer- (to hold firmly, to support, to fix in place), which also produced Sanskrit 'dharma' (that which holds, law, duty, cosmic order), Greek 'thrónos' (throne — a firm seat), and 'themeílion' (foundation). The connection between 'affirm' and 'dharma' is striking: both descend from the same root meaning 'to hold firm,' but one became a speech act of confirmation while the other became one of the most profound concepts
In American law, witnesses may 'affirm' rather than 'swear' an oath — a distinction that originated to accommodate Quakers, who interpreted the Bible as prohibiting oath-taking. This legal accommodation has existed since the 17th century and was written into the U.S. Constitution.