The modesty subroutine was added to Data's programming by his creator Doctors Noonian and Juliana Soong during his "childhood", to remedy Data's lack of concern regarding his own nudity.

This subroutine was added in response to the objections of the colonists on Omicron Theta over having an anatomically correct android running around without any clothing on. Data did not feel it was necessary for him to wear clothing because he did not suffer from the elements. (TNG: "Inheritance")