If the Roman sword was used for stabbing, why didnt they use a spear like the hoplites? Does it have something to do with balance?
The simplest answer is that the gladius was not just for stabbing. It was a versatile weapon which could both cut and thrust at close range. The Roman manipular system was much more flexible than the phalanx, especially on rough terrain, and we think that the maniples fought in a looser formation than their Macedonian phalanx opponents (but there is some debate about that). The gladius offered ... well, more ways to kill in close quarters. The typical hoplite spear was 7 or 8 feet, and the Macedonian sarissa even longer in some cases. The favorite Roman tactic, in all periods, was the charge, throwing the pila along the way at close range, right into the faces of the enemy, and then to lay into them with the gladii while they were still staring in disbelief at their friends with javelins through their necks and shoulders. To hear about the grisly results of a cutting/slashing weapon on the ancient battlefield, look no further than Livy. This passage is from after a skirmish between Macedonians and Roman cavalry in 200 BCE (and the cavalry are, apparently, using the gladius here)
With the view of doing more to win the affections of his men and make them more ready to meet danger on his behalf, Philip paid special attention to the burial of the men who had fallen in the cavalry action and ordered the bodies to be brought into camp that all might see the honor paid to the dead. But nothing is so uncertain or so difficult to gauge as the temper of a mass of people. The very thing which was expected to make them keener to face any conflict only inspired them with hesitancy and fear. Philip's men had been accustomed to fighting with Greeks and Illyrians and had only seen wounds inflicted by javelins and arrows and in rare instances by spears. But when they saw bodies dismembered with the Spanish sword, arms cut off from the shoulder, heads struck off from the body, bowels exposed, and other horrible wounds, they recognized the style of weapon and the kind of man against whom they had to fight, and a shudder of horror ran through the ranks. Even the king himself felt apprehensive, though he had not yet met the Romans in a pitched battle (31.34.4; transl. Roberts)