TL;DR: The actual revelation that the players did something horrible is very hard to pull off well. It's easy to piss off your players if you do it wrong, and I wouldn't advise to focus exclusively on that plot twist with the idea that the players will think it's brilliant. However, stories about people doing horrible things because of misinformation are great, and there are many ways to make them work. I've presented four below; check the subheaders.
Why focussing on the plot-twist itself is risky
As the DM, you are the eyes and ears of the players. If you just tell them "These are Goblins" and then after the players kill them say "Oh, they were really innocent Humans" then it's very likely that to your players (as in, the people around your table) it won't come off as "Oh wow, what a plot-twist" but more like "Oh damn, we cannot trust what the DM says". You are supposed to be the voice of Truth. Whatever the DM says is True. When you remove this assumption, players will be unable to trust anything that is said to them, because they have no way to interpret the world beyond what you tell them.
Unless you approach this very carefully, by giving lots of hints that are just subtle enough that at the end the players realize they should have definitely known, then it's likely going to be a very big letdown instead of a big revelation. It takes an experienced DM who knows his group well to walk on the balance between "just subtle enough" and "not giving the clue away too soon", so I would not advise it to a new DM.
While these kinds of twists are awesome in books and can be awesome in RPGs if you do it just right, they can also easily be the ruin of a campaign. It's easy to end up at the end of the book, read the part where "it was all a dream" and think to yourself "what a terrible ending".
Instead, I see four other ways to do approach stories with a plot twist like this. Either get your players in on the plot from the start and see where the story goes, force the character's hands while everybody knows they don't want to, skip over the part leading up to the revelation and just start after that or really mind-game the characters instead of using magic.
Getting your players in on the plot
This one is simple. It assumes that the players would like playing in a story where there characters are going to kill a bunch of innocent humans while under the effects of a mind-affecting spell, even though they themselves already know.
In this case, you just tell them that "The Wizard cast a mind-affecting spell on you. You know think that the Artifact is guarded by evil Goblins, even though they are not."
You don't have to tell them what is guarding the thing, but this lets them roleplay blissful ignorance, doesn't require you to leave clues for the players (since they know) and at the end the characters can go "Oh no, what have we done!" since they didn't know.
It prevents any sour feelings at the end with the players realizing they have been fed false information by the DM and everything they have done since who knows when being a lie. And you still get the interesting reveal "just what did we kill/steal?"
Forcing your character's hands
This one is, I think, a bit more traditional D&D mind-set. The players and the characters both don't want to kill innocent Humans, but you're going to make them do it anyway. There's a great 5e spell for this called Geas
You'll need to find a way to cast it on the players (since it's single target and has a 1 minute cast time) but after they are under the effect, your Wizard can give them the suggestion "The guardians of the Artifact are evil and must be slain", and now the players will take 5d10 damage if they refuse to work towards that goal. At a low enough level, that's potentially fatal or at least a massive resource drain, so not something they can risk.
The players and the characters will know that they are being messed with, but outside of "suicide" and "work towards the goal... slowly... while trying to find a way to lift the spell" they don't really have any options.
Skip over the revelation
This is a great way to start a new adventure. You just start with "You are all standing near the entrance to . Around you are the corpses of the Goblins you've just cut down. Content with a job well done, you all suddenly feel as if a powerful magic lifts from your minds... as if you can see clearly for the first time in a long time. Suddenly, the corpses are no longer Goblins. They are Paladins, and you killed them. A vague image of being enchanted by forms in your mind.. it was.. yesterday? Last week? Last month? You're not sure, but you haven't been yourselves and you don't know what other horrible things you've done since then. Now... what do you do?"
It gives you the exact story you want, you can make the players do whatever you want, and they won't feel bad for having been lied to by you. (They may feel bad about having been mind-controlled though. Ask your players if they mind having their characters controlled like this before doing it; some players really dislike this idea and domination magic in general.)
Have your NPCs misinform the players
This one is a harder, but probably the most rewarding and the closest to the revelation you wanted. However, it also has the highest chance of the players subverting your storyline. So only do it if you're not attached to a specific outcome.
Rather than saying "magic makes you think it's Goblins", have the NPC Wizard or an accomplice pretend to be an ally to the players. Have them try to convince the characters and the players that the guardians of the artifact are corrupt and in need of killing. Give them whatever checks they've earned to see through the ruse, but also rely a little bit on D&D player's desire to bite down on plot hooks and go out and slay things. Make it sound like an ordinary adventure, but give them enough options to find out they are being conned if they care enough to double-check their new "employer".
Because this time you are talking as an NPC when you say "These people are evil" instead of as the DM when you say "These are Goblins", the players will blame the NPC for their wrongdoings, or themselves for believing an NPC. The DMs voice is truth, but the NPC lies through his teeth.
(Bonuspoints: you can make the group of noble guardians of the cave actual Goblins to show the PCs how easily they are manipulated into doing horrible stuff just by thinking a race of creatures is evil.)