Short for 'defective', which means 'the Ultimate', superlative, better than good...
This started some time after Michael Jackson's "I'mBad" video, in which 'bad', of course, meant 'good'.
So, to denote a meaning that means the ultimate superlative of 'good', people started using 'defective', which of course is the ultimate superlative of 'bad', and which then was simply abbreviated to 'def'.