to maintain a state of equllibrium in the atom
The universe is based on a state of equillibrium . If you keep a glass at one end of a rod , you will need to place another at the other side to balance it out , or else you may end up with a broken glass . Atoms are supposed to be neutral or else it could happen that like charges repel and only unlike charges attract each other , hence becoming completely against the fact of even having matter as it is basically made up of molecules which themselves are made up of atoms . Hence, leading to the conclusion of having equal number of electrons and protons in the atom to give it a neutral or no charge.