Why has God ordained government? (Ro 13:1) What is its purpose and role?

Asked another way, if all people were basically good, everyone loving one another as themselves, what need would there be for a State, rulers forcing us to comply with its laws? In such a world, what could government do more effectively than charities and businesses?
But we aren’t there yet, not even close, so God commissions rulers to punish evildoers. (Ro 13:4) This requires officials to use force, to have an army and police. which costs money, so we must pay them for what they do. (Mt 22:21)
Government’s right to take our money by force implies a duty to limit its scope to the tasks God’s given it, and to divide and balance its power to deter corruption. Excessive, unchecked government invariably abuses this authority, usurping the people’s right to do with their own resources as they wish, placing a privileged few in control and presuming they know better, which they seldom do.
But the fact that a few always have much more than they need while others are struggling, tempts us to legalize Robin Hood, stealing from the rich to help the poor. Call it Communism, Socialism or whatever we like, entitling people to healthcare and welfare, comfort and security, apart from their own labor and industry is problematic since it rewards laziness (2Th 3:10) and foolishness. (Pr 13:23) There’s a basic natural law at work here, violated at our own peril: God feeds the birds (Mt 6:26), but He doesn’t drop it into their nests. Enabling and/or rewarding irresponsible behavior isn’t love. (2Jn 1:6)
The purpose of government is to protect its citizens, punish evildoers, and praise those who do well (1Pe 2:14), while enforcing laws which are consistent with God’s Law. Torah enables the poor to help themselves to the resources of others only in an extremely limited context (De 23:24-25), but it exhorts us all to voluntarily help each other out when in need. (De 15:7-8) There’s eternal wisdom here which we do well to heed.
Healthy government focuses on the role God’s given it, and divides and balances its power to mitigate abuse. Let people cooperate voluntarily in meeting the remaining needs of society as they see fit. The closer to this model we can get, the better off we’ll all be.