Earlier quoted context omitted.
Banks can’t base mortgage on possibility of dying: https://www.55places.com/blog/60-year-old-can-get-30-year-mo... Even barring the legal requirement, banks already prices mortgages such that they can handle being stuck holding the title with no payment. Down payments or government guarantees prevent them from holding the bag unless the housing market takes a big downturn.
Yes they can, they just can't use your age or other protected characteristics in the calculation of those odds. The ECOA doesn't say anything about health.
Additionally, the underwriter of the mortgage sells off the mortgages to other banks once everything is closed up. If a chance of death had any impact on repayment probability, this resale value would be impacted (where age discrimination doesn’t apply) and that doesn’t happen today.