Summer (June–August) is the peak season and the obvious choice. Days are very long — in late June, Copenhagen gets light from around 4am until past 10pm. The weather is mild rather than hot, typically 18–22°C, and the country comes alive with outdoor concerts, festivals, and street life. The Roskilde Festival in late June/early July draws 80,000 people and is one of Europe's best music events. Copenhagen's streets are packed through July; Bornholm and the coast get very busy in August. Book accommodation well ahead.
Spring (April–May) is underrated. Tivoli Gardens reopens in April, the countryside turns green, and the tourist crowds haven't yet arrived. Prices are lower and the light already has that Nordic quality.
Autumn (September–October) can be excellent: crisp weather, the summer rush over, and good cultural programming in the cities. Museums are well attended but not packed. Restaurant booking is easier.
Winter (November–March) is cold, grey, and dark — but that's exactly when hygge makes sense. Copenhagen's Christmas markets run through December. The longer-established ones, at Tivoli and on Kongens Nytorv, are worth seeing. January and February are quiet and cold, with some attractions closing or reducing hours. Prices are significantly lower.
In terms of rainfall, Denmark is fairly wet year-round with no dramatically dry season. Pack a light waterproof regardless of when you go.