As a complement to chrisl's answer, it is worth noting that the
datasheet of the microcontroller (here the ATmega328P), under a section
named “Typical characteristics”, has a subsection named “Pin Driver
Strength”. This subsection has some typical voltage-vs-current curves
showing that:
- the curves are not quite linear, although the non-linearity is small
at 5 V supply voltage
- they depend strongly on temperature
- near ambient temperature, the pin behavior is close to an ideal
voltage source in series with a 25 Ω resistor.
The curves go only up to 20 mA, as the behavior for higher currents
is not characterized.
From this, you can guess the voltage reading you expect. For example, if
you use a 470 Ω resistor (which is safe), the output pin resistance
and the external resistor make a voltage divider. The expected voltage
you read is
(5 V) × (470 Ω) / (470 Ω + 25 Ω) = 4.747 V