Cain does, as John Wheeler says, derive from the Gaelic Christian name Catháin, which I turn gave rise to Ua Catháin (later O Catháin) in several locations in Ireland, and to MacCathdin on the Isle of Man. The most powerful were the O Catháin clan of Co Derry, from which clan about a third if Cain’s descend. The next most common sources are the O Catháin clan of south Galway and the O Catháin clan who held O’Cahanes Castle on Iniscatha in the Shannon estuary. The Eoghan Ua Catháin, Abbot of Clonfert, Co Gslway was most likely a member of the south Galway O Catháin clan. He may be the first recorded O Catháin.
From DNA results there are other smaller sources of the name in Ireland, Scotland and England, of more recent date than the O Catháin clans of south Galway and Co Derry.