Well the history is a bit sketchy. Apparently it was dug between 1717 and 1732 to provide water for the fortress. They failed to hit underground reservoirs but the well is being filled anyway (they don't know exactly how - filtering from the top of the fortress or siphoning action from the waters below).
The water is known to actually rise when there's no precipitation and the water levels of the river below are dropping so who knows?
Some stories also tell that between it being dug and filling with water there was a period when the well was used as a dungeon/oubliette. I don't know how reliable these are but in the sixties a team of divers found two human skeletons at the bottom. Also, in 1954 a deranged husband murdered his wife and threw her down the well.
Oh, and apparently there's a grate over the well now. It wasn't there when I came to visit as a kid!