The proverbial question of "how many angels can dance on the head of a pin?" is mainly associated with medieval theology of the Scholastic school, the best-known representative of which being Saint Thomas Aquinas, the 13th-century Christian philosopher (and a Dominican monk).
In those times, the Symbol of the Church was considered to be more important than that for which it stood for. This is because at that time, the commonners were not considered to be capable of understanding the underlying truth and therefore the commoners should accept the Symbol of the Church as the truth. This was however exactly the opposite of Aristotle's philosophies.
The Pope, on observing that Aristotle's philosophies governed in concepts of science and logic becoming stronger competition to the power of the Church, unofficially appointed St. Thomas to be the first official psychologist, a person who supposedly studied the nature of the soul of man. St. Thomas was charged with the responsibility of coming up with logic and reason, the same tools used by Aristotle, to keep the Church in its position of power.
The answer to the proverbial question of "how many angels can dance on the head of a pin?" essentially hinges on one's understanding of the nature of spirit. Angels, as it was believed, were pure intelligences and as such not material, but limited. Therefore, they could have location in space but not extension; rather like a point which in theory has position but no magnitude. Thus an angel could not occupy space, like a needle point but could be located on a needle point.
As such, if an infinite number of angels could fit on the head of a pin, then an angel would have no material substance and would therefore definitely be a purely spiritual, non-spatial and non-material entity. If, instead, only a finite number of angels could fit on the head of a pin, then the spiritual universe would not be much different from the physical universe.
Nowadays, this proverbial question often appears when ridiculing theologians.