So you buy the $500k property with $125k in cash and a $375k mortgage (25-30% down is typical for investment mortgages). Depreciation *plus mortgage interest expense* leads you to (for tax purposes) more or less break even on this investment after 10 years and so you pay no tax.
After those 10 years are up, you've now paid off around $68k of the principal, plus the asset has gained $250k in value. So from your initial $125k of capital invested, you now have ~$400k in capital that you can leverage into a $1.6M property in a 1031 exchange. That bigger loan comes with a much larger mortgage interest expense, so you continue to earn no taxable income while growing a larger and larger asset and taking a (relatively modest) cash-on-cash return.