In a nutshell, the 3-speed system costs more to make.
The 3-speed and the 7-speed options use different systems. While the 7-speed uses a derailleur to shift the chain to different gears, the 3-speed uses an internal hub to change the gear ratios.
3-speed bikes cost more because the internal hub system costs more than the 7-speed derailleur system. However, the internal system does come with an advantage: internal hubs require less maintenance and are easier to adjust.
The advantage of a 7-speed, along costing a little less, is that it gives you a wider range of gears. This means that you will have both easier gears for getting up hills as well as higher gears for going faster.