Your question is based on incorrect assumptions.
Generally, there's no "penalty", per se, to make a withdrawal from your RRSP, even if you make a withdrawal earlier than retirement, however you define it. A precise meaning for "retirement" with respect to RRSPs is largely irrelevant.*
Our U.S. neighbours have a 10% penalty on non-hardship early withdrawals (before age 59 ½) from retirement accounts like the 401k and IRA. It's an additional measure designed to discourage early withdrawals, and raise more tax. Yet, in Canada, there is no similar penalty.
Individual investments inside your RRSP may have associated penalties, such as the dreaded "deferred sales charge" (DSC) of some back-end loaded mutual funds, or such as LSVCC funds that generated additional special tax credits that could get clawed back. Yet, these early withdrawal penalties are distinct from the RRSP nature of your account. Choose your investments carefully to avoid these kinds of surprises.
Rather, an RRSP is a tax-deferred account, and it works like this: The government allows you to claim a nice juicy tax deduction, which can reduce your income tax at your marginal rate in the year you make a contribution, or later if you should choose to defer the deduction.
The resulting pre-tax money accumulated in your RRSP benefits from further tax deferral: assets can grow without attracting annual income tax on earned interest, dividends, or capital gains. You don't need to declare on your income tax return any of the income earned inside your RRSP, unlike a regular investment account.
Here's the rub:
Once you decide to withdraw money from your RRSP, the entire amount withdrawn is considered regular income in the year in which you make the withdrawal. Thus, your withdrawals are subject to income tax, and yes, at your marginal rate. This is always the case, whether before or after retirement.
You mentioned two special programs: The Home Buyers' Plan (HBP), and the Lifelong Learning Plan (LLP). Neither the HBP nor the LLP permit tax-free withdrawals. Rather, each of these programs are special kinds of loans that you can borrow from your own RRSP.
HBP and LLP loan money isn't taxed when you get it because you are required to pay it back, and you pay it back into your own RRSP:
- If you pay it back according to the corresponding Plan, the resulting funds will still eventually be taxed when finally withdrawn.
- If you don't pay it back according to corresponding Plan, then the CRA deems that year's portion of your plan repayment to be income, and taxes it accordingly, at your marginal rate, as if you had made a withdrawal.
You always pay income tax at your marginal rate on your RRSP withdrawals.**
* Above, I said a precise meaning for "retirement" with respect to RRSPs is largely irrelevant. Yet, there are ages that matter: By the end of the year in which you turn 71, you are required to convert your RRSP to a RRIF. It's similar, but you can no longer contribute, and you must withdraw a minimum amount each year.
Other circumstances related to age may qualify for minor tax relief intended for retirees, such as the Age Amount or the Pension Income Credit. Generally, such measures don't significantly change the fact that you pay income tax on RRSP withdrawals at your marginal rate – these measures raise the minimum you can take out without attracting tax, but most do nothing at the margin.**
** Exception: One might split eligible pension income with a spouse or common-law partner, which may reduce tax at the margin.