This depends on the shape/distribution of your data. See the plot below.
The upper left graph depicts a linear relationship, so a linear function suits your data best. The upper right graph, however, is definitely not linear. A linear fit would be bad in this case. Here, we would need an exponential function in order to properly fit the data. Likewise with the polynomial and logarithmic cases (bottom two graphs).
Here's the R-code to create the above graph:
x <- runif(100,1,10)
y <- 3*x +rnorm(100,0,1)
z <- 0.3*exp(x)+rnorm(100,0,1)
a <- 1.1*x^5 - 13*x^4 +8*x^3 -12*x^2 -19*x+1+rnorm(100,0,1)
b <- log(x)+rnorm(100,0,0.05)
plot(x,y,main = "Linear Relationship")
plot(x,z,main = "Exponential Relationship")
plot(x,a,main = "Polynomial Relationship")
plot(x,b,main = "Logarithmic Relationship")
In practice you will have gathered data and your task is to model the relationship. First you should plot your data to see how it is distributed. If have decided which fit the appropriate one is, then you can pick one of several functions in R to estimate the models based on the data. For example, lm() can efficiently create linear models.