I presume that this would be "Flatland: A Romance of Many Dimensions" (written 1884 under the pseudonym "A.Square", real name Edwin Abbott Abbott).
Plot summary from wikipedia:
The story describes a two-dimensional world occupied by geometric
figures, whereof women are simple line-segments, while men are
polygons with various numbers of sides. The narrator is a square, a
member of the caste of gentlemen and professionals, who guides the
readers through some of the implications of life in two dimensions.
The Square dreams about a visit to a one-dimensional world (Lineland)
inhabited by "lustrous points", and attempts to convince the realm's
monarch of a second dimension; but is unable to do so. He is himself
visited by a three-dimensional sphere, which he cannot comprehend
until he sees Spaceland (a tridimensional world) for himself. This
Sphere visits Flatland at the turn of each millennium to introduce a
new apostle to the idea of a third dimension in the hopes of
eventually educating the population of Flatland. From the safety of
Spaceland, they are able to observe the leaders of Flatland secretly
acknowledging the existence of the sphere and prescribing the
silencing of anyone found preaching the truth of Spaceland and the
third dimension. After this proclamation is made, many witnesses are
massacred or imprisoned (according to caste).
After the Square's mind is opened to new dimensions, he tries to
convince the Sphere of the theoretical possibility of the existence of
a fourth (and fifth, and sixth ...) spatial dimension; but the Sphere
returns his student to Flatland in disgrace.
You can download the whole book for free here at Project Gutenberg.