What is the need of voltage divider in buck converter?
I am not able to understand that why can't we connect output voltage as a feedback voltage to the error amplifier
If the output voltage you want is equal to the reference voltage used by your buck controller, you may be able to connect the output directly to the feedback pin.
But usually, the reference voltage is a fairly low value like 0.8 or 1.2 V. A typical controller will adjust the duty cycle until it sees an equal voltage at the feedback pin.
So if you want a higher output voltage than that, you should create a voltage divider that will produce the reference voltage value at the feedback pin when the output has reached the voltage you want.
Conceivably, somebody could produce a controller IC that allows you to supply your own reference voltage, but voltage dividers are cheaper and easier to make than good references, so most customers would prefer the controller IC provide a fixed internal reference and let them just make a voltage divider.