Star Wars Theory: R2-D2 Didn't Know Anakin Skywalker Became Darth Vader. R2-D2 served Queen Amidala and later Anakin Skywalker, accompanied by C-3PO. Unlike the golden protocol droid, R2-D2 never had a full memory wipe, so he was well aware of all events that happened around him.
His memory was wiped at the end of Revenge of the Sith. A blabbermouth like him can't be trusted with sensitive information.
During Palpatine's reign as Emperor, his apprentice's true identity was kept a secret, leaving only a few Star Wars characters aware Anakin was Darth Vader. Besides Obi-Wan, Master Yoda also knew the truth, as well as Ahsoka Tano, R2-D2 and C-3Po, and even Senator Bail Organa.
To answer the original question, I'm pretty sure that R2 never knew that Anakin became Vader. He wasn't there when Anakin was named Vader, he didn't know what happened on Mustafar. All he knew is that Anakin told R2 to stay with the ship, and that was the last time R2 saw Anakin.
C-3P0's memory was wiped at the end of Episode III so if he wasn't told he had no idea that his maker was the future Darth Vader. R2-D2 remembers it all and if I had to guess he is quiet sad about Anakin's turn to the dark side.
Yoda recognized R2-D2 during The Empire Strikes Back.
R2-D2 was present when Padmé gave birth to Leia and Luke, so he knew Luke was Anakin's son – but what he didn't know was that Anakin became Darth Vader. In addition to that, Anakin's fall was surely a painful event in R2-D2's life, one that he definitely wouldn't like to remember or even talk about.
As such, by the time of Anakin and Padme's marriage, Anakin was the owner of C3PO and Padme the owner of R2D2 (or the state of Naboo).
Of course, the Father almost immediately wiped Anakin's memory, because he couldn't very well achieve balance knowing what he knew of his future. That's very interesting, though. It means that the Father knew that Anakin will become Vader, will destroy the Jedi, will literally annihilate whole worlds….
Anakin was still very young, so he grew up and became a Jedi with R2 at his side. Star Wars: The Clone Wars detailed their friendship at length, devoting entire arcs to it. They were inseparable, even as Anakin's faith in the Jedi Order and the Republic started to falter.
C-3PO had his memory wiped at the end of Revenge of the Sith. R2-D2 did not, but why he never told Luke the truth is actually quite simple. That ends up happening when you make the prequels after the originals lol. Bail Organa had Captain Antilles erase C-3PO's mind shortly after the twins were born.
R2-D2 was in on the scheme to keep the secret away from Luke and Leia. He was devoted to the Skywalker family, and at the guidance of Obi-wan and Yoda, he would have maintained that secret in order to help protect the twins.
C-3PO accidentally became part of the Battle of Geonosis when his head was affixed on top of a battle droid's body after a mishap in the Geonosian droid factory. R2-D2 and C-3PO witnessed the secret wedding between Anakin Skywalker and Padmé Amidala on Naboo.
In The Phantom Menace, set 32 years before A New Hope, R2-D2 is portrayed as belonging to the Naboo defense forces, one of three astromech droids deployed for repair duty onboard Queen Padmé Amidala's (Natalie Portman) starship as it attempts to get past the Trade Federation blockade.
Darth Vader didn't learn he had a daughter until Return of the Jedi, when he stood before Emperor Palpatine. The Emperor's power probed Luke's mind, attempting to goad him to fall to the dark side, and he discovered Leia's existence. "Sister," the Emperor taunted.
Do R2D2 and C3PO know that Darth Vader is Anakin? Threepio had his memory wiped at the end of Revenge of the Sith. He doesn't even know Anakin was Anakin.
In The Phantom Menace, when Qui-Gon Jinn meets tiny Anakin Skywalker and his mother, he goes on about how the Force is like, crazy strong with Anakin or whatever, and then asks his mother about Anakin's dad. Shmi Skywalker is pretty clear in her answer: There isn't a father. She was impregnated by the Force.
Qui-Gon Jinn is seen by many as the best of the Star Wars prequel era's Jedi, and there is evidence that he could have even stopped Anakin Skywalker from falling to the dark side of the Force.
Shmi was buried at the farm with a gravestone marking her grave. After her husband Cliegg Lars died, he was buried next to her.
R2-D2, sometimes spelled Artoo-Detoo and often referred to as Artoo, was an R2-series astromech droid manufactured by Industrial Automaton prior to 32 BBY, who would participate in major galactic events for nearly two centuries alongside the Skywalker family.
When Luke entered Jabba's palace on Tatooine his lightsaber was still being stored inside R2-D2. It is likely that he wanted to keep the lightsaber as a last option and instead use the Force on its own to convince Jabba to free Han Solo. This meant that he would be able to keep the amount of casualties to a minimum.
After C-3PO and R2-D2 landed on Tatooine, Jawas picked up the two droids, fitting them with restraining bolts. The Jawas sold the robots to Owen and Beru Lars and their nephew Luke Skywalker, a seemingly minor event that would change the fate of trillions in the galaxy.
After the battle, R2-D2 and C-3PO were the sole witnesses to the marriage of Anakin Skywalker and Padmé Amidala in Lake Country. After this Padmé gave ownership of R2 to Anakin while she kept 3PO.
“It's good to fly with you again, my old friend,” the old man said, so softly Han wasn't sure he had heard him right. C-3P0 didn't; his memory was wiped at the end of Revenge of the Sith to prevent him from spilling the beans.
He does. In the comic Star Wars Tales #6, we see an interaction between Vader and C-3PO. In the comic, Boba Fett brings Vader C-3PO's remains. Vader instantly recognizes C-3PO, and is reminded of his childhood.