Back in the day, doing something bad would normally earn you a slap or a knuckle-rap from a schoolteacher.
Literal
Long-ago [topic-は], bad things [object-を] do [when-と], school [attributive-の] teacher [from-から] open-palm [object-を] take-[or-たり] fist [object-を] receive things [subject-が] natural was.
A nostalgic comment on corporal punishment in past Japanese schools. ~たり~たり lists representative examples of actions. くらう is a colloquial verb for 'to take/receive (an unwanted blow)' — often used for punches, yells, scoldings, etc. 拳固 ('fist') is specifically the clenched fist as a weapon. 当たり前 'taken for granted, commonplace.' The conditional ~と marks an automatic/habitual consequence.