No one knows with 100% certainty why guinea pigs have that name. The most popular theory is that they are called ‘pig’ because of their porcine shape and little piggy squeals. The resemblance is nothing to do with kinship, though - GPs are not closely related to pigs at all, but are rodents, in the same family as hamsters, gerbils, mice, and their bigger South American cousins the Capybara and Coypu.
A misunderstood name, whichever way you look at it. For starters, do you think this looks like a pig?
There are other misconceptions about the name too. It used to be widely believed that a guinea pig originally cost one guinea in the pet trade. 'Guinea' was a British term for one pound sterling plus one shilling (£1.05 in modern UK currency, which is about $1.30). It's a fun anecdote, but probably untrue, as guinea pigs were being bought and sold before guineas were ever used as currency.
The ‘guinea’ part of the name is most likely to be based on a misunderstanding. It was based on the belief that the animals were first brought to Europe from Guinea in West Africa. It's possible that they stayed temporarily in that country's Atlantic ports as a break during their voyage from South America, though, so there's some truth in the tag after all.