The purpose of hell, primarily, is to punish all who sin and rebel against God. Hell was originally made for Satan and his demons who were the first to rebelled against God, but because all unredeemed people are rebellious and unbelieving like Satan and because they are in fact sons and daughters of Satan, hell will be their destination as well (Rev. 20:15).
This punishment is absolutely necessary because of the holiness and justice of God; for His holiness demands that sin must be punished; and the punishment must be rendered to each one according to his misdeeds (Rom. 2:5-6).
A second purpose of hell is to provide an eternal place for those who reject God apart from those how love God. As I see it from scripture, those who are in hell will continue to do wrong forever and those who are in heaven will continue to be holy and practice righteousness forever (Rev. 22:11). And so a special place for hell, separate from heaven, is necessary.
Moreover, since those unredeemed will have no desire to be righteous, but will continue to love their sin and the darkness, hell will be a place of outer darkness, a place where they will be able to sin as much as they want. However, since they will continue to sin against God forever, He, because of His holiness and justice, must continue to punish them forever, according to their misdeeds (Rev. 21:8, 27, 22:15).