If the passport is NOT full/exhausted/damaged/details-changed, then it can be renewed only in it's last year of validity. If any of the above happens, then it can be renewed anytime.
A catch will be that the current one's remaining validity will not be carried over, and the new one's ten years will start from that day of issuance.
People renew passports early all the time, reasons being damage, full, name change, and such. The general consensus is renew it any time in the last year as soon as it's possible, as you never know when you might need it.
Sourc: Personal experience, renewed first in 9 year 2 months, 10 months before expiry, because a visa required 6 months minimum validity. Second renewed after 5 years as it was full.
Edit: also, my passport has my name two words as first name, and second name section is empty. A year later I found that it never gets read at electronic swipe countersbat airports because of that second name field empty, and check in agents have to split and enter it manually. I asked Indian embassy here in doha, they had no issues with issuing me new passport with name split, but remaining 9 years were going to go away. So, always, new passport is valid immediately for ten years from today, old one will be expired/cancelled with immediate effect.