Me and my friend were wondering about this. It seems dumb, but of course there must be nuanced reasons as to why most major militaries fought wars in such a manner for such a long time. Could anyone explain why infantry fought in lines?
These posts here from /u/eighthgear, /u/DonaldFDraper, and /u/tyn_peddler, respectively, seem to answer a lot of the questions.
In very general terms, it boils down to command and control and protection in a melee, particularly against cavalry. More intuitive skirmish tactics - where lines would spread out more thinly and provide less dense targets for enemy fire - would exist for most of this period among light infantry and screening forces, and they would be increasingly popular with the general line infantry as the technology changed to reduce the risk of being overrun in a melee.
Command and control is the easiest to understand. Dense, linear formations can be extensively drilled and allow for officers to better control their soldiers on a loud, chaotic battlefield. Well-defined positions make it easier for well-drilled soldiers to keep from being disorganized in the chaos of combat, and it becomes easier for commanders to understand where their forces are and direct them appropriately.
Less intuitive is the defense in a melee. Because of the long reload times, poor accuracy, and low effective range of smoothbore muzzleloading firearms, enemy forces closing to a melee was a very real possibility, especially with cavalry. In such a melee, dense formations have an advantage, and loose groups of soldiers are going to end up isolated and ganged-up on. With cavalry, this becomes even more important - not only due to the greater mobility of cavalry, but because anticavalry tactics like the infantry square relied in part on dense formations to deter horses from charging.
You may be interned in this previous answer featuring u/tyn_peddler and u/TRB1783
People have linked a lot of great responses but check out the FAQ on this one https://www.reddit.com/r/AskHistorians/wiki/faq/militaryhistory/earlymodernwar Edit: Specifically the answers under "Why did European Armies use Line Tactics?" by u/erictotalitarian and u/elos_
The rough answer is that it was the best way to fight.