This is an interesting question and has been the subject of much research over the years but first I must point out that the image formed on the retina of the eye is real and inverted.
It is the brain that does the inverting of the inverted image on the retina for you to perceive the world around you as upright.
In 1896 George M Stratton wrote a paper Some preliminary experiments on vision without inversion of the retinal image in which he explained how the eye "adapted" to having an "upright" image formed on the retina, an effect that was "time limited".
Stratton produced the inversion by having convex lenses placed at one end of the tubes and the other ends of the tubes were attached so that the tubes were over the eye sockets. Te convex lenses at the ends of the tubes inverted produced an inverted image which was then inverted again by the eye to form an "upright" image on the retina.
Others have done similar experiments and the results show that the brain "adapts" so that after wearing inverting "spectacles" for a time the image of the world becomes "upright" and then after removing the inverting "spectacles" the world starts of being "inverted" but after a span of time becomes "normal".
In this video,Erismann and Kohler: Inversion goggles, an experiment is described using prisms? as the invertors.
A translation from the German by @weeniks in reproduced below.
0:00 The reversal glasses and seeing “right side up”
0:12 A perception experiment over a period of 10 days
0:20 From the institute of experimental psychology at the University of Innsbruck, led by Prof. Dr. Theodor Erismann
0:35 Camera: F Wollersperger
0:40 The reversal glasses and her first consequences
1:52 First Stage (1st-3rd day): Clumsiness in external behaviour, errors in grasping, inverted seeing
2:19 Unsteadiness of mirror images with tilting head movement (what is meant is what is called “rolling” motion in aviation)
3:17 Dr M sees this beam below him, hence…
4:05 Partially, already now “right side up” seeing, but always connected with the idea, of hanging oneself upside-down in the room
4:28 Second stage (3rd – 5th day): Improvements of external behaviour (errors still occur). “Turning right side up” of the optical image – but only under the influence of external factors, otherwise still upside-down seeing.
5:42 Factors benefiting the “turning right side up” of the image.
5:48 a) Direct connection to the own body: Touch
6:25 b) Also direct touch with a stick turn the image right side up
6:57 Even the long extensible stick does it: Ground and people within reach of the stick turn right side up.
7:24 c) The “magic pendulum” added to the image. The effect of weight perception.
7:57 d) The usual right side up image
8:14 Two heads in opposite direction are shown to Dr. M. – and what happened next:
8:48 And now how Dr.M. sees it (The appearance of the white arrow indicates the switch of the head that was first seen wrongly)
9:10 Both head seem “right side up”, but still opposed to each other: paradox, not visually depict able impression.
9:32 Third stage (6th – 10th day): Full certainty of external behaviour, even in complex situations. “Right side up” seeing. (Exceptions become increasingly rare). Tactile- and visual world match!
10:25 Resting objects are now, despite head tilt (!), perceived as fully motionless. Before (stage 1): Inverted seeing, unsteadiness of arrow. Now (stage 3): Right side up seeing, resting arrow.
11:35 End of experiment: Removal of reversal glasses. The seeing with free eyes!
12:12 But already after a couple of minutes Dr M sees the previously inverted right side up again.