The best times to visit Melbourne are autumn (March to May) and spring (September to November), when the weather is at its most settled and mild and the city's festival calendar is busy. Summer (December to February) is warm and can hit sudden heatwaves, with the Australian Open and beach days but higher prices; winter (June to August) is cool, grey and the cheapest time, though rarely freezing. Melbourne is famous for 'four seasons in one day', so whatever the month, pack layers and be ready for the weather to change quickly.
Melbourne's weather is famously changeable and can swing from warm sun to cold wind and rain within a single day. Always carry a light waterproof layer and something warm even in summer, check the forecast, and don't be caught out on a day trip by a sudden change.
Like the rest of Australia, Melbourne has strong UV and you can burn quickly on a clear day even when it isn't especially hot. Wear sunscreen, a hat and sunglasses, and seek shade in the middle of the day, especially by the bay.
Melbourne is a safe city, but take normal late-night care around busy nightlife areas such as King Street and parts of the CBD on weekends, keep an eye on your belongings in crowds, and use a licensed taxi or rideshare to get home rather than walking alone.