let's consider a conditional sentence:
if / when ( condition a = true) & ( condition b = true ), then c
which might be simplified to:
if / when (a & b), then c
a & b, then c
now, replace these symbols with the sentence of analects:
if / when ( 入則孝﹒出則弟﹒謹而信﹒ 汎愛眾﹒而親仁 = true) & ( 有餘力 = true ), then ( 則 )以學文
if / when ( 入則孝﹒出則弟﹒謹而信﹒ 汎愛眾﹒而親仁 ) & ( 有餘力 ), then ( 則 )以學文
since (condition a = true) implied that those actions are already performed, the original place is replaced by the character "行"; list these actions in front, so the sentence changed to:
( 入則孝﹒出則弟﹒謹而信﹒ 汎愛眾﹒而親仁 )﹒if / when ( 行 ) & ( 有餘力 ), then ( 則 )以學文
further, omit the "if / when", "&", "then" :
( 入則孝﹒出則弟﹒謹而信﹒ 汎愛眾﹒而親仁 )﹒( 行有餘力 ), 則以學文
last, adding back the "子曰﹒弟子", we'd have:
based on james legge's translation:
when he has time and opportunity, after the performance of these things, he should employ them in polite studies
行, in this context, it means "after the performance of" "入則孝﹒出則弟﹒謹而信﹒汎愛眾﹒而親仁"
about the rationale of such arrangement, i would say:
1 it's classical chinese, complied in a few thousand years ago.
2 it started with "子曰", which implied it's authoritative, in an assertive manner, so the "if / when" is omitted.
have fun :)