Here is another example of linear regression that compares the speed and distance of a certain car.
data(mtcars)
mod <- lm(dist~speed, data = cars)
X <- cars$speed
Y <- cars$dist
xax <- list(title = "Speed",
titlefont = list(family = "Times new Roman"))
yax <- list(title = "Distance", titlefont = list(family = "Times New Roman"),
range = c(0, 130))
fig <- plot_ly(x=X, y=Y, type = "scatter", mode = "markers", name = "data",
width = 800, height = 430) %>%
add_lines(x=X, y = fitted(mod), name = "fitted") %>%
layout(xaxis = xax, yaxis = yax) %>%
layout(margin = list(l = 150, r = 50, b = 20, t = 40))
config(fig, displaylogo = T)
With this plot you can tell the distance from the regression line to the respective points by hovering over the respective points or regression line. The farther away the point is the more error there is at that value. There are minimal outliers and there is a consistent positive distribution trending upwards. This means that the speed and distance of a car have a positive correlation i.e. the faster a car is, the more distance it covers which makes sense.
Confidence Interval
The direction of the regression line indicates whether or not the relationship between the two variables is positive or negative.
For example, in this final example of a linear regression model there is a positive relationship between the length of a Sepal and the length of a Petal within an iris. This means that as the independent variable(length of a Sepal) increases, so does the dependent variable(length of a Petal).
The opposite relationship is present if the direction of the regression line is switched. Therefore the relationship between variables is now negative.

The gray shaded region represents the confidence interval which shows the possible values that could exist in the dataset. The confidence interval is the range of values within which we are confident the true regression line (population regression line) lies, based on the observed data at our disposal.
Conclusion
Linear Regression allows us to: Increase sample size without intervention, Estimate what a continous population(all data points) would look like based on a sample of data(Confidence Interval) and most importantly, to predict the relationship that 2 variables have in a given dataset.
Linear Regression is important in the real world because if you are for example, working for Tesla and you are in charge of ensuring that self driving cars are safe for drivers and passengers, you can’t assume that the technology used to build the cars keeps drivers and passengers safe because human lives and the repuation of tesla is potentially at stake if the technology is faulty for even 100 cars. Instead you must be able to predict based on a smaller sample of data, say 100 self driving cars, and be able to determinea consistent trend of cars that are able to deal with tough weather conditions, or other reckless drivers. This is one of many many examples of how linear regression is used for greater efficiency and safety for products that companies make worldwide.