The libnoise Web site has a good explanation of the mathematics behind this noise function. In particular, with regards to the prime numbers:
These large integers are primes. These integers may be modified as long as they remain prime; non-prime numbers may introduce discernible patterns to the output.
noise::IntValueNoise3D
actually operates in two steps: the first step converts the (x, y, z) coordinates to a single integer, and the second step puts this integer through an integer noise function to produce a noise value roughly between -1073741824 and 1073741824. noise::ValueNoise3D
just converts that integer to a floating-point value between -1 and 1.
As for why noise::IntValueNoise3D
performs all those convoluted operations, it basically boils down to the fact that this particular sequence of operations produces a nice, noisy result with no clear pattern visible. This is not the only sequence of operations that could have been used; anything that produces a sufficiently noisy result would have worked.