Hitting max depravity upgrades any of the already existing traits with a certain chance (it feels to be around 50-75% from experience, but no hard data on that). It does work on both positive AND negative traits, but it cannot create a new one. The upgrade works in three possible levels, with numbers in question depending on the trait (+5%, +10%, +15% or so on) and what you get depends solely on chance, it seems. The levels of the trait already on the slave have no effect on the result, outside of not getting benefits from traits already past their cap. They can't be re-rolled after proccing. If you have earlier upgraded stats from any source (notably, Barbara birth room upgrades, which rock), the upgrade is overwritten visually without you losing anything, so a past +9 to max births can become +3, but you'll get the total +12 in actual stats.
The most optimal way is to have even a bit of every trait either in positive or negative before hitting max depravity to maximize the effect. The result is calculated on hitting 50 depravity, so savescumming is an option.