The distance to the horizon varies with the size of the planet you're standing on and your height above the ground. Since the horizon occurs where your sight line is tangent to the sphere, we can diagram a two-dimensional version of the horizon with a right triangle:
R is the radius of the planet and h is our height above the ground. We'd like to know either the ground distance to the horizon (s) or the sight distance (d). Where R is much larger than h, s and d should be pretty close. Here we'll just find d, since all we need is the Pythagorean theorem.
This is the exact formula, however for most terrestrial uses R is orders of magnitude larger than h. For example, Earth's average radius is 3958.8 miles, and Mount Everest is 29,032 feet high, meaning Everest is only 0.14% the radius of the Earth. We can make this clearer in the equation above by factoring out a 2Rh:
Since evelations and altitudes are usually given in feet (or meters), but we don't need the same precision for how far we can see. Given a height in feet, we're only curious how many miles (or kilometers) we can see. Taking R in miles, we can convert it to feet, do the calculation, then divide by feet per mile to get an answer in miles:
On Earth, these simplify to