It is meaningless to ask for distance without supplying size and temperature.
The trivial answer is that the distance with the "best" resolution will virtually always be as close as you can get without exceeding the boundaries of the frame but that's impractical in most cases.
Since each pixel measures the average temperature of the area it is viewing, pixelwise, you do not want your target to be so small or far such that it covers an area smaller than one pixel. You can calculate the area covered per pixel at a given distance using the overall field of view of the sensor and the pixel dimensions of the sensor. For example, a square pixel 10x5 sensor with a field of view of 90 degrees will cover an arc of 9degrees x 18 degrees.
The smaller or farther away the target you want to specifically spot, the narrower field of view and more pixels you need. And the dimmer or farther away the target, the more sensitive your pixels need to be since that one tiny hot spot now has to be hot enough to raise the average temperature of the entire area being measured by the pixel above ambient by a measurable amount.