To produce the greatest happiness of the greatest number of people.
The sentence implies the happiness will belong to the people, thus, they will be happy.
To produce the greatest happiness from the greatest number of people.
The sentence implies the happines will be produced using people. Such process could make them rather unhappy if overdone. Who is to become happy is not mentioned here, it could be a single person or multiple persons. Maybe the happiness is to be accumulated and returned to the people from whom it was produced, at a later date.
To produce the greatest happiness to the greatest number of people.
This looks ungrammatical to me. We can "produce something to someone", but this is usually said in formal contexts, such as "to produce papers, documents, drafts, estimates..", and the recipient is usually a government, a regulatory body, the police etc.
Of is a possessive preposition. I quote from Wikipedia:
the child's bag might also be expressed as the bag of the child
our cats' mother might be expressed as the mother of our cats
The people's happiness -> The happiness of the people.
When you choose the prepositions from or to, they start to work with the verb produce, resulting in the combinations produce something from and produce something to.
I produced my documents to the court.
We produce cottage cheese from milk.
The proposition of, on the other hand, does not combine with the verb produce. It combines with the noun word happiness.
This is not always so: of could combine with, or depend upon, other verbs. Different prepositions have different dependency patterns:
I cured him of his tooth-ache.
A poetic example of of being dependent upon a verb:
Wisdom enough to leech us of our ill
Is daily spun; but there exists no loom
To weave it into fabric; undefiled
Proceeds pure Science, and has her say; but still
Upon this world from the collective womb
Is spewed all day the red triumphant child.