To accurately determine the distance between Earth and Mars at any given time can end up being a fairly complicated orbital mechanics problem. However, using a few basic facts and relations, the possible range of values can be determined. Mars can be anywhere from about sixty million to four hundred million kilometers away from the Earth. How these numbers are actually obtained is described below.
First, the planets orbit the sun in paths that are roughly circular, but are technically ellipses with fairly low eccentricities. In other words, mathematically their paths are ellipses, but they are very round ellipses which generally look like circles. The Earth’s orbit can usually be approximated as a circle with an orbital radius of about 149,598,000 kilometers (also called an astronomical unit, or 1 AU) because its eccentricity is less than .02. The eccentricity of Mars is higher, .0934, so it is usually much less accurate to say that the orbit of Mars is a circle. Mars orbits at an average distance of 1.524 AU, or about one and a half times the average distance of the Earth. Using its eccentricity value then, Mars orbits at a distance between 209,160,000 km and 249,232,000 km.
The closest that Earth and Mars can be occurs when the two planets are lined up on the same side of the sun. This condition is called conjunction. The actual minimum distance would occur when conjunction also matches up with Mars being at its closest approach in its ellipse to the sun (called periapsis). This minimum distance between the two is the difference between Martian periapsis radius and Earth radius (assumed to be a circle in this analysis), or 59,563,000 km.
Finally, the farthest away that Earth and Mars can be occurs when the two planets are in opposition, or lined up on opposite sides of the sun. The maximum distance also occurs when Mars is at its farthest distance from the sun, or apoapsis, when in opposition. This maximum distance between the two is Earth’s orbital radius plus the Martian apoapsis radius. This comes out to 398,830,000 km.
Reference:
Orbital Mechanics, by John E. Prussing and Bruce A. Conway, 1993.