I wonder if triangle stack would be a better design to handle thrust and stability of the flight.
The boosters are in a row because it's easy to assemble them horizontally when they're in a row. If they were stacked, the lower 2 stages would have to carry the weight of the third, so they'd need to be made stronger.
The plan is also to have the center core to run at a lower thrust setting.
In a triangle setup with the 3 cores as they are now, i.e. 1 two-stage rocket with the payload on top, plus 2 boosters), total thrust (as well as weight) would be asymmetric, which is undesirable: to compensate, you'd have to gimbal the engines and thrust at an angle, which is less efficient than thrusting along the velocity vector.
Putting the 3 cores in a triangle has another drawback: the attachment points now overlap each other, making it more difficult to have 2 identical "side" cores.
Underfilling one of the side cores to stagger separation is possible, but reduces performance because the core will shut down earlier.
Back in the 1960s, British company BAC was working on MUSTARD, a two-stage to orbit fully reusable vehicle. This consisted of 3 lifting bodies of identical shape. 2 were the boosters, the third was the spacecraft.
There were 2 ways to stack the 3 vehicles: in line, or in a triangle.
BAC studied both configurations (plus lots of others) and found the in-line configuration was the better one, in part because of the balance problems of the triangle (from 'British secret projects volume 5: Britain's space shuttle', by Dan Sharp, page 149). Given that Mustard was a low-budget R&D program, the fact that different booster configurations have been studied tells me the Falcon Heavy configuration was not arrived at by accident, IOW, SpaceX will have looked at the alternatives and discarded them because they did not offer a benefit over the one they chose to implement.
Finally, consider history: every rocket with 2 boosters has them in line instead of in a triangle. Ariane 4, 5, 6. Titan IIC, 34D, Delta IV Heavy, Space Shuttle, to name a few.
Edit: A configuration with 3 first stages in a triangle, plus a second stage and payload in the center of that triangle would be worse: now you have to run all 3 stages at the same power, and have to ditch them at the same time. This means the first stage has a shorter total run time compared to the real-world configuration.
In RW, the center core is run at a lower thrust setting. So when the 2 boosters separate, the center core still has fuel left and can keep running for a while. This increases performance over running the 3 cores at the same thrust.
So for a triangle with the second stage in the middle, you'd need a new, larger second stage to compensate for the lower performance of the first stage.
This configuration reduces commonality with the F9: second stage is unique, you'd need a new interstage to connect the 3 cores with the second stage, this interstage needs separation mechanisms to separate it both from the cores and from the second stage (while the F9 interstage stays attached to the core). You can't recover the interstage any more. Interstage gets much heavier, reducing performance.
The other answers have excellent reasons for why the 3 boosters on the Falcon Heavy are in a line, however they haven't mentioned the asymmetrical weight distribution that making a triangle would cause.
Consider: 2 regular, "unloaded" boosters (no fairing/payload) and one "loaded" booster in a triangle. The booster / corner with the payload would be heavier.
The row works better for the intended purpose. The center booster will not be consuming fuel as quickly as the side boosters. This will allow it to continue on for a time after the side boosters have been dropped off.
If one were to do a triangle, it would be more stable, but would not allow for releasing two of the boosters separate from the third.