How does the shape of screens (that is, different "width x height" values while keeping the same total displaying area) affect the quality for a given optimal viewing distance?
Depends on what your standard of quality is. If your standard is maximal retina coverage, then, well, you've got round eyeballs, so a 1:1 aspect ratio would be the "best" rectangular shape. But they don't make square TVs, let alone circle-shaped ones, which would be "better". On the other hand, if you watch a lot of television, you'll get the most use out of your pixels with 16:9, which is what most stuff is broadcast in these days. If you watch more movies, then maybe you prefer 2.39:1. Video games? 16:9. Flight simulator? Maybe you want something panoramic. The best aspect ratio for you is the one that most closely matches the content you plan to consume most often. And aspect ratio and viewing distance are unrelated; one has no impact on the other.
I do not understand your question. As it is I would say nothing.
Get a 16x9 inches monitor. It measures 16 x 9 inches. Now rotate it 90°. It has the exact same total displaying area but now measures 9 x 16 inches. The "optimal" viewing distance is the same.
If you are referring to different aspect ratios, the unit that is important and easier to get is the native linear PPI.
Find out the horizontal resolution used and divide it by the horizontal physical measure of the display area.
If your monitor has 1920 x 1080 px, use 1920. If the monitor measures 21 inches on the horizontal size: 1920/21 = 91.4 PPI. Use that value to compare other monitors.