It is actually a little hard to determine precisely what was the first modern computer. Computing machines were in use middle 1800's. These machines had some aspects of a modern computer, but the computations were done mechanically, not electrically. Also, player pianos have some attributes of a modern computer.
It is generally agreed, however, that the first modern computer would be the Eniac machine, developed by the army in the 1940's. The army needed a way to more efficiently calculate balistic tables for artillery.
Modern computers work by basically cleverly configuring a series of on off switches to do useful computations. Prior to the development of the solid state transistors, the fundamental "switch" that was used was a vacuum tube. The Eniac machine used vacuum tubes as the switches. It had over 17,000 vacuum tubes, over 5,000,000 hand soldered joints, weighed 30 tons, and occupied over 1,800 square feet. Interesting to note that many of today's pocket calculators have more computation power than this machine.
Vacuum tubes were prone to failure, so it turned out that the machine would be down every day or two because of a burned out tube.
As it turned out, I don't believe the machine was ever used to calculate ballistic tables. The physicists on the Manhattan Project heard about the machine, and then took most of the time on it in developing the Atom Bomb.