A certain mass wants a certain orbit to balance gravity between the sun and earth.
So long as densities are similar, that distance will be at a point which gives a total eclipse.
If the moon was the same size and made of lead or cheese, it would be different.