early 13c., "notably large, bulky, or strong" (a sense now obsolete), from Old English mægen- "power, strength, force," used in compounds (such as mægensibb "great love," mægenbyrðen "heavy burden;" see main (n.)), probably also in part from or influenced by cognate Old Norse megenn (adj.) "strong, powerful, mighty."
Sense of "chief, principal, prime" is from c. 1400. That of "principal or chief in size or extent" is from 1590s. Main chance "opportunity of enriching oneself" is by 1570s, from the game of hazard. Main course in the meal sense attested from 1829. Main man "favorite male friend; hero" is by 1967, African-American vernacular.
common adverbial suffix, forming from adjectives adverbs signifying "in a manner denoted by" the adjective, Middle English, from Old English -lice, from Proto-Germanic *-liko- (cognates: Old Frisian -like, Old Saxon -liko, Dutch -lijk, Old High German -licho, German -lich, Old Norse -liga, Gothic -leiko); see -ly (1). Cognate with lich, and identical with like (adj.).
Weekley notes as "curious" that Germanic uses a word essentially meaning "body" for the adverbial formation, while Romanic uses one meaning "mind" (as in French constamment from Latin constanti mente). The modern English form emerged in late Middle English, probably from influence of Old Norse -liga.
<a href="https://www.etymonline.com/word/mainly">Etymology of mainly by etymonline</a>
Harper, D. (n.d.). Etymology of mainly. Online Etymology Dictionary. Retrieved $(datetime), from https://www.etymonline.com/word/mainly