The to in this sentence is not the Infinitive Complementizer to. It's the Preposition to, part of the complex preposition prior to, which means the same as before:
- Samson had been a strong man prior to having his hair cut.
- Samson had been a strong man before having his hair cut.
So the gerund clause having his hair cut is the object of the preposition prior to.
In other words, to having is not a Constituent of this sentence; to is part of the constituent prior to, and having is part of the constituent having his hair cut. They just happen to be next to each other here.
Not every infinitive is marked with to; not every to marks an infinitive. Constituents, not strings.
Addendum. The reason why
- *Samson had been a strong man prior to his hair are being cut.
is because the gerund phrase requires a gerund, and are is not a gerund.
Apparently there is some confusion here between the Progressive construction, which uses a tensed form of be plus the -ing form; and the Gerund construction, which is untensed and requires no auxiliary verb, just the -ing form. These are two uses of the -ing form of the verb.