Castor and Pollux were originally Greek gods, but when the Romans were fighting the Etruscans in 496 BC, the Roman soldiers saw visions of Castor and Pollux fighting on their side. When the Romans won the battle, they decided to try to get Castor and Pollux to fight for Rome from now on. The Romans built Castor and Pollux a fine new temple to live in. They wanted the gods to be happy in their new home.
In some versions of the story, both Castor and Pollux are the sons of Jupiter (or Zeus). So they’re both immortal themselves. But in other versions they are both mortal, or Castor is mortal while Pollux is immortal. Sometimes the story goes that Pollux (who was immortal) missed his twin Castor, and so he convinced his father Zeus to let them stay together. Now both spend half their time up in the sky as gods, and the other half of their time under the earth in Hades, as mortals.
Roman people thought of swearing by Castor or Pollux as a not too serious kind of cursing, like saying “Gosh darn it!” today. So the plays of Plautus and Terence are full of people saying, “I’ll do it, by Pollux!” or “You’d better not, by Castor!”. “By Castor!” (“ECASTOR” in Latin) was a curse that only women used, although both men and woman used “EDEPOL” (“By Pollux!”).