Sweden is a long country with many different spoken dialects, but something began to change in the 17th century. At this time, Sweden recognized the importance of having an impressive capital city as a status symbol to reflect its growing power. The development of Stockholm as the capital meant that many noble families moved to the city to embrace a more modern way of life.
This new population in Stockholm primarily spoke regional dialects such as västgötska, småländska, sörmländska, and uppländska. As the nobles socialized and interacted, their dialects began to influence each other, and this blend of dialects formed the basis of what we now call rikssvenska.
Originally, the Swedish standard of pronunciation was shaped by the everyday speech of the upper class and nobility. However, over the last few centuries, the rise of a middle class has led to a standard form of Swedish that more closely aligns with how words are written. Despite this evolution, many similarities between today's spoken Swedish and the mix of accents from the 1600s can still be found.
Source: Språktidningen