‘Taking the piss’ may be a reference to a related expression, ‘piss-proud,’ which refers to morning erections. These have long been popularly attributed to arising by consequence of a full bladder – thereby being something of a ‘false’ erection – and so in a metaphoric sense, someone who is ‘piss-proud’ suffers from false pride. It is possible, therefore, that ‘taking the piss’ refers to the deflating of this false pride, through disparagement or mockery. As knowledge of the expression’s metaphoric origin became lost on users, ‘taking the piss’ came to be synonymous with disparagement or mockery itself, with less regard to the pride of the subject.
Note – ‘taking the mickey’ may be an abbreviated form of the Cockney rhyming slang ‘taking the mickey bliss’, a euphemism for ‘taking the piss.’
PS: WordPress suggests as a tag ‘Gerard Depardieu’ no doubt in reference to his urinating on a plane gaffe. Hilarious.