basically:
employed/self-employed = pay NI (it is reflected in your payslips, accounts, etc)
unemployed = Don't have to pay NI (provided you dont claim any benefits and there will be breaks in your contributions!!)
Overseas employment in EU and certain other countries = reciprocal NI aggrement in place anyway
Overseas employment elsewhere= voluntary NI contributions if you want.
I believe NI contrubutions have nothing to do with ILR provided you don't claim benefits and pay NI when employed/self-employed.
UKBA specifically quotes :
Public funds do not include benefits that are based on National Insurance contributions. National Insurance is paid in the same way as income tax and is based on earnings. Benefits to which a person is entitled as a result of National Insurance contributions include:
contribution-based jobseeker's allowance;
incapacity benefit;
retirement pension;
widow's benefit and bereavement benefit;
guardian's allowance; and
statutory maternity pay.