There are contexts where the two prepositions are interchangeable, and others where they are not.
For example, they tend to be interchangeable when talking about attendance or presence at school:
- John is at school today
- John is in school today
But "at school" means more than just being currently present in school. It idiomatically means that someone is of school age, normally attending school.
For example:
-Is your son at school yet?
-No, he's only 2.
In your example, which talks about someone's historic performance, "at school" is most appropriate, because it would idiomatically refer to his period of schooling rather than just the hours he was physically present "in" his school. Saying "he did well in school" just doesn't sound right - it could be taken to mean that he didn't do well when he was outside of school (eg at home).