And did France just give it to them randomly?
Because the French gave up all of their other African colonies but decided to stay in Algeria as a base for their African operations. This was also influenced by the fact that Algeria has a huge amount of oil, which was just beginning to become a commodity in the western world. Also the French didn't just give Algeria independence randomly. There was a large war between the two which Algeria won in 1962.
Just to point out: 123 VIVA L'ALGERIE