It wasn't a philosopher, but was first spoken by Leonard Nimoy's Spock in Star Trek II: The Wrath of Khan. However, philosopher Jeremy Bentham had a similar quote: "It is the greatest good to the greatest number of people which is the measure of right and wrong."