verb+ing forms

I don’t know what the school is thinking[color=red] having a wrestling unit.

—From Diary of a Wimpy Kid

What information does the red part give us?

Thanks.

In “I don’t know what the school is thinking”, the speaker is questioning or expressing surprise at the school’s behaviour. “having a wrestling unit” explains what the school is doing that has prompted this reaction.

I assume a “wrestling unit” is a course/department that teaches wrestling.

Can we say “I don’t know what the school is thinking [color=red]to have a wrestling unit”? If so, what’s the difference?

I guess some people might say “…to have a wrestling unit”, and there no difference in meaning, but to me it seems iffy. If you want to use a preposition, I prefer “I don’t know what the school is thinking by having a wrestling unit”. Opinions on this may differ between speakers.