For any part of a transaction to be taxable, the contract must first have a gain. A life insurance contract has a gain when the gross cash value exceeds the cost basis (generally premiums paid less adjustments) of the contract.
Generally, when a taxpayer takes a distribution from a life insurance contract the IRC allows the taxpayer to recover the cost basis before any gain is withdrawn, but there are some exceptions. Distributions (including loans) from life insurance contracts classified as Modified Endowment Contracts under the IRC are taxed gain-out -first. Also, distributions from a contract within the first 15 contract years may be subject to gain-out-first taxation depending on the size of the withdrawal and other factors.