The Infamous Noun entered the English language through the slave trade. Oxford English Dictionary gives a 1587 reference to a cargo of 400 male slaves from Africa, “nee*ars.” While there are various English spellings, none of them seem to feature the double “g”. The low Dutch spelling in colonial times was “ne**ar.” The Dutch took Africa slaves to Western Massachusetts in 1617. They had the first slave codes here, even offering “half-freedom” arrangements by 1644.
Changing the “e” to “i” seems to be an American modification, perhaps to make a harsher, more insulting sound. In any event, it comes from the African slave trade, and brings a lot of bad karma with it.
Some people can’t seem to resist using it, perhaps seeking some form of emotional release. It’s remarkably easy to avoid, if you want to. Even rappers and hip-hoppers are criticized for using it. Some people want to bury it. The all-time best advice may be, leave it alone.