This question already has an answer here:
Why is it that black boxes don't float?
From what I gather the answer is:
So they will not float away from a water crash site. The ping can be heard underwater with sonar. Finding the ping, finds the site.
But why not have two black boxes one that floats and one that stays with the aircraft?
That way if a plane is lost at sea, if we find the black box floating, we could use the data to find the other black box and the crash site. Plus the benefits of having a redundancy are enormous.