Depends on the software.
Best if you maintain full backwards compatibility and all support involves mandatory upgrade. Unless your business model depends on selling new versions every few years.
It requires a precarious balance: make the support period too short and people will leave in favor of better supported competition. Make it very long and the costs will gobble you up.
The usual approach of "keep the previous version supported until new one is released (plus some)" is okay if the release cycle isn't too fast - like, one new version a year, or longer. So, if you release 4.x, you keep support of 2.x for another couple of months to encourage migration, and keep supporting 3.x until a few months past release of 5.x. But if you release a new version every 6 months, you should keep the support longer.
Still, specifics of the job may require much longer support period. Say, it's industrial embedded - software running machinery worth many millions of dollars. So something breaks, and you just can't say "this is not supported any longer" three years after deploying. OTOH, maintaining free warranty support, while nice, is not mandatory. Additional option against disgruntled customers who don't want, or can't upgrade, is paid support - valued at the cost of keeping it up plus a profit.