Given a set of 2d points you can use Ransac to estimate a fitting line.
But the resulting line should only be estimated using inliers and not be contaminated by the outliers.
Example of ransac iteration: bad model estimated | final ransac iteration if everything went well :-)