Leibniz's mathematical handling of insurance problems, demography, and life annuities