Which is why employers would usually pay you for your notice period but tell you not to come to work, or at least that's the standard practice in the UK.
To my mind, notice periods are good for both sides - the employer gets peace of mind that if you choose to leave you'll still have a period of time for handover and winding your job down and the employee knows that they've got a bit of a safety net if they're let go. There are generally clauses that allow notice not to be paid in specific circumstances as well, generally for gross misconduct.