As I understand it the population of Sweden and Denmark should have been about the same in the 17th century and Denmark is a lot more suited to agriculture (with the exception of Skåne in southern Sweden). How is it that there are 4 million more people living in Sweden?
Your premise that the population was about the same in the 17th century might be true. Sweden has had excellent record keeping since the 18th century (and more limited before that) and they where one of the best in this field.
http://www.tacitus.nu/historical-atlas/population/scandinavia.htm
Sweden has had a bigger population for centuries, there was a lot of immigration to North America (1/3 of Norway emigrated to North America) but Sweden was also the highest here in true numbers.
TL;DR: Sweden always has had a bigger population from the time period you specified.