If you keep sugar stored in a sealed airtight container away from moisture and humidity the sugar should last nearly forever.
After you open a bag of sugar the granulated sugar will last for up to 2 years in the pantry before it starts to go bad.
Sugar really never spoils to the point it gets unsafe to use but the sugar can become hard and clump up but you can break the sugar apart using a meat tenderizing hammer and the sugar can then be used.
If you want to keep the sugar longer than a few months you should store it in airtight containers which also helps keep ants and other bugs out of the sugar.
Sugar can actually be keep for many years so if you want to stock up on sugar you certainly can as it never becomes unsafe to use.