You'd better not get involved with religions like that before stupidity rubs off on you.
Literal
Idiot [subject-が] transfer before [target-に] that-kind-of religion [target-に] involve-not-[colloquial-ん] [side-ほう] good.
Rough, opinionated speech. 移る ('to transfer, move, spread') is here used metaphorically — 'stupidity rubs off, contagion spreads.' 関わらん is the casual/dialectal contraction of 関わらない (probably 関わらぬ → 関わらん, a Western-Japan-influenced casual form). The pattern ~ないほうがいい ('better not to') gives advice. The whole tone is dismissive and rough — possibly older masculine speech.