The numerator relates to the x-intercepts:
(-1,0) means (x+1) is a factor in the numerator.
The denominator relates to the vertical intercepts:
x = -2 as a VA means (x+2) is a factor in the denominator.
x = 1 as a VA means (x-1) is a factor in the denominator.
Since the x-intercept crosses and the VA's are "one up, one down", we know these all have odd multiplicities.
So, we think the function could be
Checking the y-intercept with this function
This checks out. That's your function: