In case they have no use to the end users and have no function, why are they given as pins instead of being just closed? Some ICs have even 4-5 NC continuously (in accordance to their pin number).
There can be several reasons.
It is easier/cheaper to use standard packages than custom ones. So if you need 4 pins, but there is a standard package with 5, you have one spare. With large packages you can have many spare pins. Removing the pins or designing a package with a custom number of pins would be very costly in terms of set-up.
They may have been used during development/testing
You might have different versions of the same series part. Some in that series might have more pins than others, so the ones with fewer pins have N/C's
You might want an oversize package for thermal performance (or size of die), and as a result you end up picking a package with more pins than you need.
The chip manufacturers packaging factory may only support a few different packages, so there may not be one available with the correct number of pins, so you go up a size.
There are probably many more, but my fingers are tired.
You may then ask, why not just connect them to something? Well, that requires more time wire bonding. It also means an increase in silicon size if you have to add the additional bond pads to the die. There may be performance related issues with bonding the extra pins (stubs in high frequency circuits?). And so on.
It's unclear what the alternative being proposed here is, but say an IC wants to sell in DIP8 format, but only needs 5-7 pins, some will remain "NC". There's no economic incentive to cut them out. Furthermore, doing that would physically destabilize the package.
There are of course different packages in which one such IC can be sold. A great example is TL431, which only needs 3 pins, but is sold in a variety of packages to suit customer demands (up to 8 pins). You'll see in the image below that in some packages several pins are used for a given function (duplicated) to increase allowable current etc. So that's one alternative for "NC".
Here's another (perhaps even more interesting) example, the TOP254 which is both an example of pin duplication, and of the [rare] pin removal (in the DIP package[s]). The duplication is again done for the same reasons mentioned before. The pin removal between C and D is to increase safety by maximizing distance (creepage and clearance). This an SMPS controller with integrated main switch. Between its D pin and everything else you [periodically] have hundreds of volts of rectified mains voltage. The datasheet even lists this among its features:
Extended creepage between DRAIN and all other pins improves field reliability
In addition to the other good reasons listed, I know that NC pins are sometimes also used when:
- The die will not fit into a package with the appropriate number of pins. The next larger (standard) package is used, resulting in unused pins. This could easily result in multiple adjacent NC pins since the larger package may have many extra pins.
- Adjacent pins are too close together to meet high voltage spacing requirements, so a NC pin is used between them.
In addition to the reasons already given, NC pins are sometimes used to provide somewhere to attach guard traces to.
On some small fine pitch packages it's difficult to get PCB traces between the pins to provide guard rings as required on very high impedance, low current inputs. Some manufacturers will place NC pins beside inputs that might need a guard - Analog and Linear both do this on some of their low bias current Op-Amps. NC in this case meaning Not internally Connected.
Here's one that might be a bit less known:
Often you'll have many devices that are the same devices with different channels. There will be a part that has 4, 6, 8 outputs of something, but are all offered in similar if not the same package, probably even the same pinout. What happens is, the silicon for the 4 output devices is the exact same as in an 8 output, except 4 pins are just labeled "NC" on the datasheet!
Not all parts or manufacturers do this, but it is definitely something that happens. You might ask then, why would anybody buy the part with more outputs than less if it's the same die? The reason comes out to be what the manufacturer of the chip guarantees and tests. A 6-output part could very well work the same as an 8-output part with the 2 NCs being in reality 2 outputs, but if the manufacturer doesn't stand by and guarantee those "NC outputs", then nobody will realistically ever use it in products intended to be sold to the market.