The sacrament is only colloquially referred to as “Last Rights”. The proper term is “Extreme Unction” or “Anointing of the Sick”.
The Catechism explains it well
Through the biblical record of anointing the sick to heal physically and spiritually, we know that we have received this sacrament through Christ.
Its purpose is to bring about that healing which we require: either physical (i.e. cancer, illness, etc.) or spiritual (sin, sinful proclivities, etc) so that we may be more properly oriented toward Christ.
It may be administered to non-catholics if there is a reasonable assumption that they desired to be Catholic, and if the rest of the sacraments are administered as well. A wonderful man in my parish had a heart attack during RCIA and received first communion, confirmation, and extreme unction on the same day.
Also typically received at “last rights” is the viaticum (“bread for the journey”, or more properly something prepared to be taken along on the journey) so you may receive Christ sacramentally on earth before meeting Him in heaven and be filled with Christ during your journey to meet Him.