The way the loan is structured, “duration to payoff” is the basic factor that determines the total loan payment per month, along with a general desire to have a stable mortgage payment (ie, the same payment every month). This drives the small amount going to principal (not the large amount going to interest).
At any given time, for a particular month, you accumulate $I in interest. This amount will be due regardless of how much principal you pay off with the payment: you have a $100,000 balance loan (right now) at a monthly equivalent interest rate of 0.5% for simplicity; so you owe 0.5%*100,000 (or $500) in interest for the month. That’s how interest works – it depends on the current value of the loan. (This is usually compound interest compounded daily, so it’s more complicated than this, but it’s about the same idea.)
Your total payment will be $I + $P. $P is where the 15 year, 30 year, etc. comes into play. When you pay some principal this month, say $100, you will have a smaller interest payment next month, right? $99900 * 0.5 is now $499.50. So, if you keep a $600 flat monthly payment, you will now only owe $499.50 in interest and pay off $100.50 in principal. The next month you pay $499 in interest and $101 in principal… etc. Eventually your principal will be $500 and your interest will be $100, because your total loan balance will be only $20000. So over time, $I+$P=payment, and I goes down while P goes up simply due to the math on the interest owed for that period. You’re not paying interest for future months or anything like that in your payment (normally); you’re just paying more interest now because you owe more now on the amount you’ve got outstanding.
The exact amount of total payment, and thus the exact amount of principal you pay with the first few payments, depends on the mortgage term. Paying $700 total (so starting at $200 a month principal) clearly has a lower amount of total payments than $600 a month. The mortgage company sets the payments up based on a formula that determines you will have exactly 360 equal payments (30 years), or 180 equal payments (15 years), or whatever schedule you prefer. The equal payments is assumed to be in your interest (to have a stable monthly bill) – but you’re (usually) permitted to pay more principal at any time if you prefer.
This is only applicable to fixed rate mortgages; variable rate mortgages may not have constant payments (or may have longer or shorter terms based on the variability of interest).
I recommend you find a mortgage calculator, figure out a payment schedule, then plug it into excel – see the amount of P+I in the first month, then calculate how much I should be in the second month, how much P, etc., all the way down to 360 payments (or whatever your loan term is). I did this once and it made this whole bit make a lot more sense to me.